Brian Webster
Brian Webster

Reputation: 30865

Gridview - Edit Mode - When I press return on my keyboard, the edit item index changes to the first row

When I am in edit mode on any row of my GridView and I press Return while the focus is in one of the row's textboxes, instead of triggering the update button, my GridView1.RowEditing event is fired with a NewEditIndex of 0

This causes the first row to become editable and I lose any values typed into the previous row.

How can I stop this from happening?

Thanks

Upvotes: 1

Views: 755

Answers (1)

cortijon
cortijon

Reputation: 983

Take the GridView RowCommand event that fires when you hit the return button, check to see if the event that triggered it was a user keystroke on a grid row in edit mode, and have it call the same method that your Update button command would call, then set EditIndex to -1, which indicates no row is being edited.

Upvotes: 1

Related Questions