标签:bsp key param ret tar string 添加 datatable color
/// <summary> /// 键值集合List转换成datatable /// </summary> /// <param name="data">数据源</param> /// <returns></returns> DataTable ToDataTable(List<Dictionary<string, string>> data) { DataTable dt = new DataTable(); foreach (var item in data[0].Keys) {//循环添加列 dt.Columns.Add(new DataColumn(item)); } foreach (var item in data) {//把数据填充到行 DataRow dr = dt.NewRow(); foreach (var ii in item) { dr[ii.Key] = ii.Value; } //把数据添加到datatable dt.Rows.Add(dr); } return dt; } //调用 List<Dictionary<string, string>> data = new List<Dictionary<string, string>>(); ToDataTable(data)
标签:bsp key param ret tar string 添加 datatable color
原文地址:https://www.cnblogs.com/macT/p/10207122.html