private static ArrayList DataTableToArrayList(DataTable data) { ArrayList array = new ArrayList(); for (int i = 0; i < data.Rows.Count; i++) { DataRow row = data.Rows[i]; Hashtable record = new Hashtable(); for (int j = 0; j < data.Columns.Count; j++) { object cellValue = row[j]; if (cellValue.GetType() == typeof(DBNull)) { cellValue = null; } record[data.Columns[j].ColumnName] = cellValue; } array.Add(record); } return array; }