用了循环往DataTable插入数据,基本代码贴在下面:纯属积累。。。
DataTable dt = new DataTable();
//添加列名
dt.Columns.Add( new DataColumn("inforId",typeof(string)));
dt.Columns.Add( new DataColumn("title",typeof(string)));
dt.Columns.Add( new DataColumn("startTime",typeof(string)));
dt.Columns.Add( new DataColumn("endTime",typeof(string)));
dt.Columns.Add( new DataColumn("type",typeof(string)));
DataRow dr;
//一个新行
dr = dt.NewRow();
dr["inforId"] = "11111111";
dr["title"] = "11111111";
dr["startTime"] = "1111111";
dr["endTime"] = "11111111“
dr["type"] = "11111111";
//加入dt
dt.Rows.Add(dr);
dr = dt.NewRow();
dr["inforId"] = "222222";
dr["title"] = "222222";
dr["startTime"] = "222222";
dr["endTime"] = "222222";
dr["type"] = "222222";
dt.Rows.Add(dr);