Converting HashTable into ArrayList and binding to DataControls

SheoNarayan
Posted by SheoNarayan under C# category on | Views : 9511
Following code snippet shows how to convert HashTable into ArrayList and Bind to DataControls.


Class MyClass
{
public static ArrayList HashTableToArrayList(Hashtable hTable)
{
ArrayList list = new ArrayList();
foreach (int key in hTable.Keys)
{
list.Add(hTable[key]);
}
return list;
}
}


Now you can use above function to Bind any DataControls like GridView.

GridView1.DataSource = MyClass.HashTableToArrayList(myhashTable);
GridView1.DataBind();

Comments or Responses

Login to post response