我动态地向gridview添加一行,并且我还想再添加一行并想要在atime显示所有行..如何动态地向gridview添加行..
答案 0 :(得分:0)
如果您使用asp.net n C#:
,请尝试此操作ChildTable table = GridView1.Rows[index].Parent as ChildTable; //get that row
if (table != null)
{
GridViewRow row = new GridViewRow(-1, -1, DataControlRowType.DataRow, DataControlRowState.Normal);
TableCell cell = new TableCell();
cell.ColumnSpan = GridView1.Columns.Count;
cell.Width = Unit.Percentage(100);
cell.Controls.Add(new LiteralControl("New Row"));
row.Cells.Add(cell);
table.Rows.Add(row);
}
谢谢,