Home All Groups Group Topic Archive Search About
Author
10 Jul 2005 4:39 AM
user
Just wondering if anyone has figured out a way to add <optgroup> to
DropDownLists?
Theoretical code that should work:

<asp:DropDownList id="ddlWeightClass" runat="server">
  <optgroup label="Light Weight">
    <asp:ListItem Value="50">50</asp:ListItem>
    <asp:ListItem Value="51">51</asp:ListItem>
    <asp:ListItem Value="52">52</asp:ListItem>
    <asp:ListItem Value="53">53</asp:ListItem>
  </optgroup>
  <optgroup label="Middle Weight">
    <asp:ListItem Value="120">120</asp:ListItem>
    <asp:ListItem Value="121">121</asp:ListItem>
    <asp:ListItem Value="122">122</asp:ListItem>
  </optgroup>
</asp:DropDownList>

Which I wish would render as:

<select name="ddlWeightClass" id="ddlWeightClass">
  <optgroup label="Light Weight">
    <option value="50">50</option>
    <option value="51">51</option>
    <option value="52">52</option>
  </optgroup>
  <optgroup label="Middle Weight">
    <option value="120">120</option>
    <option value="121">121</option>
    <option value="122">122</option>
  </optgroup>
</select>

here is a link to a similar example
http://www.webdevtips.com/webdevtips/html/accessibility/form_tags.shtml

Thank you,
Art Clark

Author
11 Jul 2005 5:36 PM
lisa
You're probably going to have to create your own control.  You'll have
to have a collection of optgroups, with each one having a collection of
listitems.

It's like a table, which has a collection of rows, each of which has a
collection of cells.

I'm looking into writing a table control that will allow me to have
tbody, thead and tfoot tags, and it's the same sort of pain in the
rear.

Sorry,
Lisa


u***@sympatico.ca wrote:
Show quoteHide quote
> Just wondering if anyone has figured out a way to add <optgroup> to
> DropDownLists?
> Theoretical code that should work:
>
> <asp:DropDownList id="ddlWeightClass" runat="server">
>   <optgroup label="Light Weight">
>     <asp:ListItem Value="50">50</asp:ListItem>
>     <asp:ListItem Value="51">51</asp:ListItem>
>     <asp:ListItem Value="52">52</asp:ListItem>
>     <asp:ListItem Value="53">53</asp:ListItem>
>   </optgroup>
>   <optgroup label="Middle Weight">
>     <asp:ListItem Value="120">120</asp:ListItem>
>     <asp:ListItem Value="121">121</asp:ListItem>
>     <asp:ListItem Value="122">122</asp:ListItem>
>   </optgroup>
> </asp:DropDownList>
>
> Which I wish would render as:
>
> <select name="ddlWeightClass" id="ddlWeightClass">
>   <optgroup label="Light Weight">
>     <option value="50">50</option>
>     <option value="51">51</option>
>     <option value="52">52</option>
>   </optgroup>
>   <optgroup label="Middle Weight">
>     <option value="120">120</option>
>     <option value="121">121</option>
>     <option value="122">122</option>
>   </optgroup>
> </select>
>
> here is a link to a similar example
> http://www.webdevtips.com/webdevtips/html/accessibility/form_tags.shtml
>
> Thank you,
> Art Clark