Friday, 22 March 2013

GridView: Having to click twice in Edit command button


When I click on the edit button. I need to click twice then it goes to edit mode. Here is my code:
protected void studentListGridView_RowEditing(object sender, GridViewEditEventArgs e)
    {
        studentListGridView.EditIndex = e.NewEditIndex;
        
    }


In the rowediting event you do need to set editindex and then databind. It should be like this:

protected void studentListGridView_RowEditing(object sender, GridViewEditEventArgs e)
    {
        studentListGridView.EditIndex = e.NewEditIndex;
        studentListGridView.DataBind();
    }

No comments:

Post a Comment