How to create/populate dynamic drop down lists in asp.net

Posted by Rajendra.prasad under ASP.NET on 4/16/2011 | Points: 10 | Views : 2996 | Status : [Member] | Replies : 1
Hi All,
In DB, a table with columns:

ID, Name & RootID.

Purpose of this table is to create/store multi-level categories within same table with different levels. Like Categories, Subcategories where categories with rootid 0 and subcategories with rootid of categories id and further other subcategories or child subcategories with rootid of subcategories and further categories with rootid of child subcategories.

Example:-
============
id name -> rootid
1 a -> 0
2 b -> 1
3 c -> 2
4 d -> 3
5 e -> 4
6 f -> 5
7 g -> 6 etc

At Design side, when level 1 drop down list is selected, if the selected item has a subcategory, then another drop down list should be populated dynamically with it respective subcategory items.

Regards,
Rajendra Prasad




Responses

Posted by: Srinivas673 on: 4/16/2011 [Member] Starter | Points: 25

Up
0
Down
ddlist.DataTextField = "parentcol";
ddlist.DataValueField = "parentcol";
ddlist.DataBind();
//Dropdown Selected changed
//get datatable first
DataTable fileName = (DataTable)objResponseDTO.ReturnObject;
var query = from images in fileName.AsEnumerable()
where images["Subcol"].ToString().Contains(dropdownSelectedvalue)
select new
{
wideimage = images["Subcol"].ToString()
}.wideimage;
//in query subcol values coming
//you bind that values to dropdown
foreach (var str in query)
{
url = str;
//here subcolvalues coming

}
this is using ours

Rajendra.prasad, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response