开发者

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()

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜