I have an ASP.NET page with a gridview control on it with a CommandButton column with active delete and select commands.
Pressing the enter key triggers the first command button in gridview, which deletes the row. I do not want this to happen. Can I change the gridview control so that it no longer responds to pressing the enter key?
There is a text box and a button on the screen. They do not need to respond to a hit, but you should be able to fill out a text box. We are currently opening a confirmation dialog to prevent accidental deletion, but we need something better than this.
This is the markup for gridview, as you can see it inside the asp.net update panel (I forgot to mention this, sorry): (I missed most of the columns and formatting)
<asp:UpdatePanel ID="upContent" runat="server" UpdateMode="Conditional"> <Triggers> <asp:AsyncPostBackTrigger ControlID="btnFilter" /> <asp:AsyncPostBackTrigger ControlID="btnEdit" EventName="Click" /> </Triggers> <ContentTemplate> <div id="CodeGrid" class="Grid"> <asp:GridView ID="dgCode" runat="server"> <Columns> <asp:CommandField SelectImageUrl="~/Images/Select.GIF" ShowSelectButton="True" ButtonType="Image" CancelText="" EditText="" InsertText="" NewText="" UpdateText="" DeleteImageUrl="~/Images/Delete.GIF" ShowDeleteButton="True" /> <asp:BoundField DataField="Id" HeaderText="ID" Visible="False" /> </Columns> </asp:GridView> </div> </ContentTemplate> </asp:UpdatePanel>
source share