如何给DataTable,DataRow 手动赋值
1个回答
展开全部
代码如下:
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();
r["学生编号"] = Guid.NewGuid().ToString();
dr["姓名"] = "222";
dr["学校"] = "444";
dr["联系电话"] = "555";
dr["家庭住址"] = "666";
MyDataTable.Rows.Add(dr);
}
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();
r["学生编号"] = Guid.NewGuid().ToString();
dr["姓名"] = "222";
dr["学校"] = "444";
dr["联系电话"] = "555";
dr["家庭住址"] = "666";
MyDataTable.Rows.Add(dr);
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询