OptGroupDropDownList: suggestions for improvement

Jul 14, 2008 at 10:12 AM
When I first tried to use the OptGroupDropDownList, I expected to be able to add the option groups by setting the appropriate values in the property sheet of the control. As far as I can see, this is not supported. The sample solution shows populating the control is done in code:
            this.ddl.AddGroup("Computers", "1");
            this.ddl.AddItem("Monitor", "12");
            this.ddl.AddItem("Mouse", "13");
            this.ddl.AddItem("Keyboard", "14");
I would like to be able to populate the control by assigning it a data source etc. This could work as follows.

The control gets an extra property DataGroupField
The data member must contain this extra field.
For example, an XML data source would look like this:
<?xml version="1.0" encoding="UTF-8"?>
    <item group="Group 1" text="Option 1.1" value="1" />
    <item group="Group 1" text="Option 1.2" value="2" />
    <item group="Group 2" text="Option 2.1" value="3" />
    <item group="Group 2" text="Option 2.2" value="4" />
The DataGroupField would be assigned the value "group".
The combox box should be populated like this:

Group 1
Option 1.1
Option 1.2
Group 2
Option 2.2
Option 2.2
The control should work out for me the correct order of adding the optgroup and option elements. I think the order would be the order of the first occurrence of any group label. If the groups are mixed up in the data source, it would be nice if the control still added the options to the correct group.
This way, it would be quite a lot easier to fill the control.
Jul 14, 2008 at 11:36 AM
Edited Jul 14, 2008 at 11:39 AM
Hello, thanks for posting your feedback. We are planning to have 2 more releases for the OptGroupDDL: the first one (should be in this August) will include collection and design-time support for item groups a lot like the way you described; for the second release we will analyze OptGroupDDL DataBinding so it can support the 'grouping' feature; I say 'we will analyze' because we might have to rewrite the ASP.NET binding mechanism and this is something we would like to avoid.