<p>I have a GridView defined like this:</p>

<pre><code>&lt;asp:GridView ID="myGridView" ruant="server"&gt;
    &lt;asp:BoundField DataField="myField" /&gt;
    &lt;asp:CommandField ShowDeleteButton="true" ShowEditButton="true" /&gt;
&lt;/asp:GridView&gt;
</code></pre>

<p>After I put a row into edit mode with the Edit button, how do I capture the Enter key and trigger the resulting Update on the row? Right now if I hit enter, the page reloads, what was entered into the TextBox is lost, and the row stays in edit mode. I know how to <a href="https://stackoverflow.com/questions/152099/i-want-to-prevent-aspnet-gridview-from-reacting-to-the-enter-button">disable the enter key entirely</a> on the form (the current workaround), but I'd like to have it fire the Update command.</p>

Well, using the knowledge from the question you linked, it's simple:
```
```
string js = "if (event.keyCode == 13) this.form.submit();"
myGridView.Attributes.Add("onkeydown", js);
```
```
As we found out in the comments, this introduces a small problem. The
```
GridView_RowUpdating
```
server event does not fire anymore, but the question author relies on it.
In short - the server event model relies on the form field
```
__EVENTTARGET
```
to be set. This form field is not sent when just calling the
```
form.submit()
```
. A solution would be to "click" the relevant button with JavaScript.
```
```
string js = "if ((event.which && event.which == 13) || " 
            + "(event.keyCode && event.keyCode == 13)) "
            + "{document.myForm.Update.click();return false;} "
            + "else return true;";
myGridView.Attributes.Add("onkeydown", js);
```
```
See
"Using the enter key to submit a form"
on AllAsp.net, which covers the issue in more detail.