DropDownList <optgroup>

G

Guest

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
 
L

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,767
Messages
2,569,570
Members
45,045
Latest member
DRCM

Latest Threads

Top