Share via


Add Option Groups in ASP.NET Drop Down List

Question

Monday, June 13, 2016 3:19 AM

Hi,

I need to populate a drop down list with option groups to be able to group the drop down list items. There are a lot of discussion on the web but more I read, more confused I get. Most of them are manually adding their tables and data items. whereas , mine is coming from a SQL database with a lot of tables joins. 

Is anyone able to guide me through how to create such a drop down list?

I need to do something like this:

http://stackoverflow.com/questions/16167862/how-can-i-add-option-groups-in-asp-net-drop-down-list

Thanks,Mary

All replies (2)

Monday, June 13, 2016 4:25 AM ✅Answered

Most of them are manually adding their tables and data items. whereas , mine is coming from a SQL database with a lot of tables joins. 

You can take a look at this article : 


Monday, June 13, 2016 6:41 AM ✅Answered

Hi Mary_Nem,

So your question is more likely related to how to read data from database , You could use ADO.NET :

ADO.NET Code Examples

Using ADO.NET for beginners

Also below article implements the HTML optgroup in a dropdownlist dynamically using ASP.NET MVC and Entity Framework :

http://www.c-sharpcorner.com/UploadFile/fc9f65/implementing-html-optgroup-in-dropdownlist-using-Asp-Net-mvc/ /

Best Regards,

Nan Yu