新增DataTable并赋值
var money = ds.AsEnumerable().GroupBy(g => g["SupplierCode"]).Select(s => s.Sum(t => (decimal)t["Money"])).ToList(); DataTable dt = new DataTable(); dt.Columns.Add(new DataColumn { ColumnName = "a", DataType = Type.GetType("System.String") }); dt.Columns.Add(new DataColumn { ColumnName = "b", DataType = Type.GetType("System.String") }); dt.Columns.Add(new DataColumn { ColumnName = "c", DataType = Type.GetType("System.DateTime") }); dt.Columns.Add(new DataColumn { ColumnName = "d", DataType = Type.GetType("System.DateTime") }); dt.Columns.Add(new DataColumn { ColumnName = "e", DataType = Type.GetType("System.Decimal") }); dt.Columns.Add(new DataColumn { ColumnName = "f", DataType = Type.GetType("System.String") }); DataRow dr = dt.NewRow(); dr["a"] = "1"; dr["b"] = 2;//ddlDept.SelectedText; dr["c"] = 3; dr["d"] = 4; dr["e"] = 5; dr["f"] =6; dt.Rows.Add(dr);