I want to insert data from two tables into a Drop Down List... The situation is like this .. I have two tables named TablePropertyCategory and TablePropertySubCategory.. As the name signifies sub category table contains the sub-category elements of category
table... I want to display the data of both tables like this:
Here ALL Resedential and All commercial is from tablePropertyCategory.. While the remaining are from
Sub-Category table..
Plz suggest how to do this alongwith the SQL -Query.. I am using MS SQL as my database..
geniusvishal
Star
13984 Points
2783 Posts
Inserting value from Multiple Table to DropDownList using MS-SQL 2005
Feb 24, 2012 09:44 AM|LINK
Hello Guys,
I want to insert data from two tables into a Drop Down List... The situation is like this .. I have two tables named TablePropertyCategory and TablePropertySubCategory.. As the name signifies sub category table contains the sub-category elements of category table... I want to display the data of both tables like this:
Here ALL Resedential and All commercial is from tablePropertyCategory.. While the remaining are from
Sub-Category table..
Plz suggest how to do this alongwith the SQL -Query.. I am using MS SQL as my database..
The link for the image is:
http://s19.postimage.org/66gqwurf7/property.jpg
Regards and Thanx in Advance
My Website
www.dotnetvishal.com
kedarrkulkar...
All-Star
34013 Points
5468 Posts
Re: Inserting value from Multiple Table to DropDownList using MS-SQL 2005
Feb 24, 2012 10:15 AM|LINK
u will not extend default dropdownlist control of asp.net.... since, dropdownlist control as such does not provide way for this
check this
http://ignatu.co.uk/articles/Adding_groups_to_the_ASPNET_DropDownList_control/
hope this helps...
KK
Please mark as Answer if post helps in resolving your issue
My Site
DarrellNorto...
All-Star
86555 Points
9624 Posts
Moderator
MVP
Re: Inserting value from Multiple Table to DropDownList using MS-SQL 2005
Feb 24, 2012 10:25 AM|LINK
Once you get your data from a database, there are a couple options that you can use to get OPTGROUP tags for an ASP.NET DropDownList.
Using WebForms:
http://www.codeproject.com/Articles/15505/ASP-NET-DropDownList-with-OptionGroup-support
http://weblogs.asp.net/jeff/archive/2006/12/27/dropdownlist-with-optgroup.aspx
Using MVC:
http://weblogs.asp.net/raduenuca/archive/2011/02/26/asp-net-mvc-extending-the-dropdownlist-to-show-the-items-grouped-by-a-category.aspx
Using jQuery:
http://irfaann.blogspot.com/2009/12/dropdownlist-control-with-grouping.html
Darrell Norton's Blog
Please click "Mark as Answer" if this helped you.