Add 1 new row for each row and then update all the records, but Why it JUST Update 1 / 2 records of Gridview?
I add 1 new row for each row in a GridView and then update all the records, but it only updates 1 / 2 records of GridView? Can anybody help me?
This is my code: 1, Add new row for or each row in GridView
protected void gvUsersL_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
GridViewRow g = new GridViewRow(-1, -1, DataControlRowType.DataRow, DataControlRowState.Normal);
//creating table Cells
TableCell tCell = new TableCell();
tCell.Text = table;
//Add Cells
g.Cells.Add(tCell);
tCell.ColumnSpan = e.Row.Cells.Count;
//Set Color for Empty Cell
g.CssClass = "bgi_1";
Table tbl = e.Row.Parent as Table;
//add rows
tbl.Rows.Add(g)开发者_如何学编程;
}
}
2, Then Update:
for (int i = 0; i < gvUsersL.Rows.Count; i++)
{
//update here
}
Can any body help me? Thanks.
Their's a method in C# for datagrid named update.
gvUsersL.update();
Not shure if this is what you acutally want but this method update you're datagrid according to the linked data.
精彩评论