gridview动态添加行(不用datatable实现)

时间:2021-07-28 12:03:05
GridViewRow newrow = new GridViewRow(, , DataControlRowType.Separator, DataControlRowState.Normal);
TableCell[] tc=new TableCell[];
for (int i = ; i < ; i++)
{
tc[i] = new TableCell();
}
tc[].Text = (GridView1.Rows.Count + ).ToString();
tc[].Text = "第一列内容";
tc[].Text = "第二列内容";
tc[].Text = "第三列内容";
tc[].Text = "第四列内容";
tc[].Text = "第五列内容";
newrow.Cells.AddRange(tc);
GridView1.Controls[].Controls.AddAt(GridView1.Rows.Count + , newrow);