PC Review


Reply
Thread Tools Rate Thread

Datagrid problem - update method not getting called?!?

 
 
Erik
Guest
Posts: n/a
 
      24th Aug 2006
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">
<html>
<head>
<title>Exp</title>
</head>
<body>

<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"
OnDeleteCommand="Delete"
OnCancelCommand="Cancel" OnUpdateCommand="Update"
OnEditCommand="Edit" UseAccessibleHeader="True"
AutoGenerateColumns="False" >
<Columns>
<asp:BoundColumn HeaderText="ID" DataField="phrase_id"
ReadOnly="True" />
<asp:TemplateColumn HeaderText="Group" SortExpression="name">
<ItemTemplate>
<%# Container.DataItem("group") %>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox runat="server" id="uxGroupUpdate"
text='<%#
Server.HTMLEncode(Container.DataItem("name").ToString) %>' />
</EditItemTemplate>
</asp:TemplateColumn>
<asp:TemplateColumn HeaderText="Phrase" SortExpression="phrase">
<ItemTemplate>
<%# Container.DataItem("phrase") %>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox runat="server" id="uxPhraseUpdate"
text='<%#
Server.HTMLEncode(Container.DataItem("phrase").ToString) %>' />
</EditItemTemplate>
</asp:TemplateColumn>
<asp:EditCommandColumn EditText="Edit" ButtonType="PushButton"
UpdateText="Update" CancelText="Cancel" />
<asp:ButtonColumn Text="Delete" ButtonType="PushButton"
CommandName="Delete" />
</Columns>
</asp:datagrid>

</form>

</body>
</html>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
The Update method can only be called on UpdatePanel with ID 'UpdatePanel1' before Render.| Jeff Microsoft ASP .NET 0 8th Mar 2008 01:13 PM
make a method called when other method is called? lukasz Microsoft Dot NET 2 18th Aug 2007 09:40 PM
Inheritance problem - Base Class method being called when Derived Class method should be called. Jeff Molby Microsoft VB .NET 3 6th Mar 2005 11:03 PM
range.find method called into a VBA function (problem) =?Utf-8?B?RXJvcyBQZWRyaW5p?= Microsoft Excel Programming 5 17th Nov 2004 12:34 PM
update problem in DataGrid's UpdateCommand method dawn Microsoft ASP .NET 1 28th Jul 2003 03:49 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 09:05 AM.