DataTable 改表数据
DTable.Columns.Add() //加列名
DataTable.Rows[i][j]=Value; //这样改值
foreach (var item in DataTable.Rows) //这里面是改不了值的
{
}
DataTable MyDataTable = new DataTable();
MyDataTable.Columns.Add(new DataColumn("学生编号", typeof(string)));
MyDataTable.Columns.Add(new DataColumn("姓名", typeof(string)));
MyDataTable.Columns.Add(new DataColumn("学校", typeof(string)));
MyDataTable.Columns.Add(new DataColumn("联系电话", typeof(string)));
MyDataTable.Columns.Add(new DataColumn("家庭住址", typeof(string)));
DataRow dr;
for (int i = 0; i <= 10; i++)
{
dr = MyDataTable.NewRow();
dr["学生编号"] = Guid.NewGuid().ToString();
dr["姓名"] = "222";
dr["学校"] = "444";
dr["联系电话"] = "555";
dr["家庭住址"] = "666";
MyDataTable.Rows.Add(dr);
}