views:

6126

answers:

3

How do I put a gridview row in edit mode programmatically?

+1  A: 

Just implement the Row_Editing event and do something like this:

protected void Row_Editing(object sender, GridViewEditArgs e) { myGridView.EditItemIndex = e.EditItemIndex; BindData(); }

Bind data will populate the GridView with the data.

azamsharp
+6  A: 

Set the EditIndex property to the appropriate row and then ReBind the GridVIew again to it's DataSource.

Hope this helps.

vmarquez
A: 

Is it possible to maintain few rows in edit mode ?. Like first row I edited and without saving that I go the second row and start editing, I still want the first row to be in edit mode until I update or cancel it. Similarly for the remaining rows.

This functionality is required since I am using the edit mode to show the detailsgrid in the mastergrid with expand(using command edit) and collape(using command cancel) link buttons.

Sunny