Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

DropDownList <optgroup>

247 views
Skip to first unread message

us...@sympatico.ca

unread,
Jul 10, 2005, 12:39:35 AM7/10/05
to
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


li...@starways.net

unread,
Jul 11, 2005, 1:36:41 PM7/11/05
to
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

raul

unread,
Aug 30, 2007, 2:12:33 PM8/30/07
to
An easy implementation of an Asp Net DropDownList with optgroup support can be found at http://www.codeplex.com/SharpPieces

Enjoy!

From http://www.developmentnow.com/g/15_2005_7_0_0_557588/DropDownList-optgroup.htm

Posted via DevelopmentNow.com Groups
http://www.developmentnow.com

raul popescu

unread,
May 21, 2008, 8:51:32 AM5/21/08
to
You can find a DropDownList with OptGroup support at http://www.codeplex.
com/SharpPieces

Cheers,
Raul

url:http://www.ureader.com/msg/1425911.aspx

Teemu Keiski

unread,
May 22, 2008, 3:27:04 PM5/22/08
to
Here's also one sample:
http://www.codeproject.com/KB/custom-controls/DropDownListOptionGroup.aspx

--
Teemu Keiski
AspInsider, ASP.NET MVP
http://blogs.aspadvice.com/joteke
http://teemukeiski.net

"raul popescu" <ra...@home.ro> wrote in message
news:874caca279c54c32...@newspe.com...

0 new messages