[ACCEPTED]-Putting a gridview row in edit mode programmatically-gridview
Accepted answer
Set the EditIndex property to the appropriate 2 row and then ReBind the GridVIew again to 1 it's DataSource.
Hope this helps.
Just implement the Row_Editing event and 2 do something like this:
protected void Row_Editing(object sender, GridViewEditArgs e)
{
myGridView.EditItemIndex = e.EditItemIndex;
BindData();
}
Bind data will populate 1 the GridView with the data.
protected void gridview_RowEditing(object sender, GridViewEditEventArgs e)
{
GridView gv = (GridView)sender;
// Change the row state
gv.Rows[e.NewEditIndex].RowState = DataControlRowState.Edit;
}
0
You may also need to know how to cancel 4 the edit. Just like you set up the "OnRowEditing" command 3 in the gridview, you need to set up the 2 "OnRowCancelingEdit" command. The backend 1 should look similar to this. (VB)
Sub gridView1_rowCanceling(ByVal sender As Object, ByVal e As GridViewCancelEditEventArgs)
gridView1.EditIndex = -1
BindData() // <-- Whatever procedure you use to bind your data to the gridView
End Sub
protected void btnEdit_Click(object sender, EventArgs e)
{
GridView1.EditIndex = 1;
}
Tested with vs-2008. fork fine.
0
Source:
stackoverflow.com
More Related questions
Cookie Warning
We use cookies to improve the performance of the site. By staying on our site, you agree to the terms of use of cookies.