Thursday, January 7, 2010

Insert Dynamic Rows in Gridview


in row  RowDataBound use this code

 Table tbl = e.Row.Parent as Table;
            if (tbl != null)
            {
                GridViewRow row = new GridViewRow(-1, -1, DataControlRowType.DataRow, DataControlRowState.Normal);
                TableCell cell = new TableCell();
                HtmlGenericControl span = new HtmlGenericControl("span");
                span.InnerHtml = "Insert Row";
                cell.Controls.Add(span);
                row.Cells.Add(cell);
                tbl.Rows.AddAt(tbl.Rows.Count - 1, row);

            }

No comments: