error when canel row in gridview
this error apear when I try to cancel row in grid view
The Grid开发者_JAVA百科View 'GridView1' fired event RowCancelingEdit which wasn't handled
In the mark up, add row cancelling edit event for the gridview
RowCancelingEdit="GridView1_RowCancelingEdit"
In the code behind add,
protected void GridView1_RowCancelingEdit(object sender, GridViewCancelEditEventArgs e)
{
//switch back to default mode
GridView1.EditIndex = -1;
//Bind the grid
Gridview1.Datasource=yourDatasource;
GridView1.DataBind();
}
If this is ASP.NET then you may have specified the name of the handler in the ASP.Net page and not implmented it in the Code Behind page.
Can you post the code where it is defined?
You will have
<asp:GridView ID="GridView1" runat="server" RowCancelingEdit="MyFunction">
Just remove the RowCancelingEdit section
Try checkng the value of "EditItemIndex" in page prerender, see if it get chaged after the first postback.
With Gridview after setting the EditItemIndex, you have to do a rebind usually by just calling your GridView1.DataBind()
精彩评论