Monday, 26 August 2013

Editing a gridview with AutoGenerateEditButton = true

Editing a gridview with AutoGenerateEditButton = true

I created a gridview dynamically and added the AutoGenerateEditButton =
true; property and i see that it adds the edit link to all the fields when
it loads the table into the gridview. But when i click the edit button
nothing happens, except for a postback. What am i doing wrong?
GridView gridData = new GridView();
gridData.ID = "test";
gridData.AutoGenerateEditButton = true;
gridData.RowEditing += (sender, e) => grid_RowEditing(tbl, e,
sender);
gridData.DataSource = tbl;
gridData.DataBind();
protected void grid_RowEditing(DataTable tbl, GridViewEditEventArgs e,
object sender)
{
((GridView)sender).EditIndex = e.NewEditIndex;
// call your databinding method here
((GridView)sender).DataSource = tbl ;
((GridView)sender).DataBind();
}

No comments:

Post a Comment