手写 DataTable 偶然看见。。留下脚印

DataTable dt = new DataTable();
dt.Columns.Add("id");
dt.Columns.Add("name");
for (int i = 1; i <= 10; i )
{
DataRow row = dt.NewRow();
row["id"] = i;
row["name"] = "name" i;
dt.Rows.Add(row);
}
gv.DataSource = dt;
gv.DataBind();

你可能感兴趣的:(Datatable)