Sunday, April 3, 2011

Dictionary as a datasource to a dropdown

Wondering how to provide the dictionary object as the datasource to the dropdown:

CODE:
--------------------------------------------------------------
//Setting the dictionary item list

dctLists.Add("hyderabad", 500020);
dctLists.Add("sec-bad", 500009);
dctLists.Add("chikkadpally", 500020);

//poplting the second ddl
ddlListWithValues.DataSource = dctLists;
ddlListWithValues.DataTextField = "Key";
ddlListWithValues.DataValueField = "Value";
ddlListWithValues.DataBind();

--------------------------------------------------------------

No comments:

Post a Comment