adding multiple rows to gridview
I add one row to gridview dynamically, and also i want to add one more row to that and want to display all the 开发者_JS百科rows ata atime.. how can i add rows to gridview dynamically..
Try this if u r using 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);
}
Thanks,
精彩评论