ASP.NEt DataTableToArrayList

private static ArrayList DataTableToArrayList(DataTable dt)
{
ArrayList array = new ArrayList();
for (int i = 0; i < dt.Rows.Count; i++)
{
DataRow row = dt.Rows[i];

Hashtable Ht= new Hashtable();
for (int j = 0; j < dt.Columns.Count; j++)
{
object cellValue = row[j];
if (cellValue.GetType() == typeof(DBNull))
{
cellValue = null;
}
Ht[dt.Columns[j].ColumnName] = cellValue;
}
array.Add(Ht);
}
return array;
}

  

posted @ 2013-04-19 11:40  放哨De老鼠  阅读(381)  评论(0编辑  收藏  举报