Thursday, May 14, 2009

Bind HashTable Data with Dropdownlist.

We can bind hashtanle with dropdownlist same way as datatable and dataset.
you have to remember that how to set DataTextField and DataValueFiled Properties
of dropdownlist.

this is the code to bind HashTable with dropdownlist in

DropDownList ddl1 = new DropDownList();
System.Collections.Hashtable hsTable = new Hashtable();
hsTable.Add("0", "India");
hsTable.Add("1", "USA");
ddl1.DataSource = hsTable;
ddl1.DataTextField = "Value";
ddl1.DataValueField = "Key";


No comments:

Post a Comment

Comments posted on ASP.Net Ajax Tutorials Blog are moderated and will be approved only if they are on-topic and not abusive. Please email me or my team for tech-support or blogging related questions. Avoid including website URLs in your comments - Thanks Author