向gridview添加多行

时间:2009-11-25 10:54:32

标签: gridview rows

我动态地向gridview添加一行,并且我还想再添加一行并想要在atime显示所有行..如何动态地向gridview添加行..

1 个答案:

答案 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);
}

谢谢,