tags:

views:

50

answers:

1

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

+1  A: 

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.

MrGumbe
Hi - Unfortunately this answer is unclear to me. I am sure that the RowEditing handler is being called when "Enter" is pressed when the focus is on any textbox of any row in edit mode.. and that NewEditIndex is being set to 0. I believe the intended behavior here should be for Enter to register the "Update" button on that row being edited
hamlin11
You should be able to bind both the event that fires when you hit enter in a text box and the button click event to the same handler method. Also, setting EditIndex to 0 selects the first row, setting it to -1 will select no rows.
MrGumbe