467,073 Members | 1,263 Online
Bytes | Developer Community
Ask Question

Home New Posts Topics Members FAQ

Post your question to a community of 467,073 developers. It's quick & easy.

Datagrid problem - update method not getting called?!?

Why isn't my update method getting called?

Pasted below is an aspx from a 1.1 application I'm working on. It has
two textboxes and a button for inserting data into the database, and a
datagrid for editing and deleting data. When a user clicks on the
"Edit" button in the datagrid, Edit() method is called and the
appropriate row is changed into textboxes. And if user clicks on the
"Update" button, the Update() method is fired. But if the user hits
the Enter key instead of hitting the Update button, the Insert() method
is fired, as if the user had hit the "Insert" button. It's as if the
location of the insertion point is getting ignored or lost somehow.

If I make the two textboxes and button invisible in the Edit() method,
everything works. But it screws up the cosmetics, so I would like to
avoid this. I also tried setting the AutoPostBack to different values
on the textboxes (both within the datagrid and without) to no effect.

Is there a way around this? I just want my Update method called if the
user hits enter.

I think

<%@ Page Language="vb" AutoEventWireup="false"
Codebehind="Exp.aspx.vb" Inherits="project1.Exp"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

<form id="Form1" method="post" runat="server">

Group: <asp:textbox id="uxGroupInsertBox" runat="server" />
Phrase: <asp:textbox id="uxPhraseInsertBox" runat="server" />
<asp:Button OnClick="Insert" Text="Insert" ID="uxIsertBtn"
Runat="server" />

<asp:datagrid id="uxPhrasesGrid" runat="server"
OnCancelCommand="Cancel" OnUpdateCommand="Update"
OnEditCommand="Edit" UseAccessibleHeader="True"
AutoGenerateColumns="False" >
<asp:BoundColumn HeaderText="ID" DataField="phrase_id"
ReadOnly="True" />
<asp:TemplateColumn HeaderText="Group" SortExpression="name">
<%# Container.DataItem("group") %>
<asp:TextBox runat="server" id="uxGroupUpdate"
Server.HTMLEncode(Container.DataItem("name").ToStr ing) %>' />
<asp:TemplateColumn HeaderText="Phrase" SortExpression="phrase">
<%# Container.DataItem("phrase") %>
<asp:TextBox runat="server" id="uxPhraseUpdate"
Server.HTMLEncode(Container.DataItem("phrase").ToS tring) %>' />
<asp:EditCommandColumn EditText="Edit" ButtonType="PushButton"
UpdateText="Update" CancelText="Cancel" />
<asp:ButtonColumn Text="Delete" ButtonType="PushButton"
CommandName="Delete" />



Aug 24 '06 #1
  • viewed: 1450

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

5 posts views Thread by Jeff | last post: by
3 posts views Thread by Jim Heavey | last post: by
7 posts views Thread by Juan Romero | last post: by
9 posts views Thread by rn5a@rediffmail.com | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.