473,320 Members | 1,859 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

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">
<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").ToStr ing) %>' />
</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").ToS tring) %>' />
</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>

Aug 24 '06 #1
0 1733

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
by: Junkguy | last post by:
I need some help programmatically causing a row in a DataGrid to "flush" its contents to its bound data (in Visual Studio 6 using Windows Forms with C#). My issue is I want to send an update to...
4
by: - R | last post by:
Hello all. I'm new to .Net so please help me out. I have a application with several "Threads" running to observe various things. From time to time each thread need to add an log entry, which...
5
by: Jeff | last post by:
IDE: VS 2003 :NET OS: XP Pro My app have a form with a tab-control on it. The tab-control have 2 tabpages. One of the tabpages displays a datagrid, and the other tabpage displays details (order...
3
by: Jim Heavey | last post by:
Trying to figure out the technique which should be used to add rows to a datagrid. I am thinking that I would want an "Add" button on the footer, but I am not quite sure how to do that. Is that...
4
by: Rod | last post by:
I posted a message to this group yesterday asking how to pass parameters to a web form that is the source of an IFrame on a parent web form. I've gotten my answer, and it works. Thanks! Now I...
4
by: jibran | last post by:
Hello. I have wrapped the DataGrid control with my own class (SmartDataGrid) adding some necessary functionality. My current webform has 2 SmartDataGrids. The first is populated by selected...
12
by: TB | last post by:
Hi All: I am trying to create a variation on the standard datagrid, whereby the datagrid is only shown after pressing some buttons. This reason for this is that I would like to use the same...
7
by: Juan Romero | last post by:
Hey guys, please HELP I am going nuts with the datagrid control. I cannot get the damn control to refresh. I am using soap to get information from a web service. I have an XML writer output...
9
by: rn5a | last post by:
A Form has a DataGrid which displays records from a SQL Server 2005 DB table. Users can modify the records using this DataGrid for which I am using EditCommandColumn in the DataGrid. This is the...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.