cancel gridview row edit mode programatically using C#

karthik k picture karthik k · Jun 29, 2011 · Viewed 22.1k times · Source

I am using a Editable GridView. On clicking edit button of a row, the row is coming in Editable mode and once I update the details of a current row, the row is getting saved and comes in normal mode.

Here I face one issue. When I make row to a Editable mode, On click of a button (which is not a part of grid) I want to bring Editable row mode to a normal mode.

Answer

Saanch picture Saanch · Jul 1, 2011

Change the gridview's EditIndex value to -1.

protected void Button1_Click(object sender, EventArgs e)
    {
        GridView1.EditIndex = -1;
    }