ASP.NET: 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();
    }

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s