public List<Dictionary<string, string>> DataTableToList(DataTable dt) { List<Dictionary<string, string>> result = new List<Dictionary<string, string>>(); if (dt != null && dt.Rows.Count > 0) { foreach (DataRow dr in dt.Rows) { Dictionary<string, string> dic = new Dictionary<string, string>(); for (int i = 0; i < dr.Table.Columns.Count; i++) { dic.Add(dr.Table.Columns[i].ColumnName.ToString(), dr[dr.Table.Columns[i].ColumnName].ToString()); } result.Add(dic); } } return result; }