473,246 Members | 1,509 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,246 software developers and data experts.

UpdateCommand Event won't fire

SAL
Hello,

I created a datagrid where I set the Events to there associated functions
(i.e. Grid1_UpdateCommand, etc.). All these Events I have established work
as they are suppose to except for my Grid1_UpdateCommand.

I load my datagrid via a Select query. When my DataGrid is populated I have
a column with an Edit button in it. When you Select Edit to edit the row you
want, that column changes the Edit button to an Update and Cancel button.
The Cancel works fine, but when you modify the data in that row and press
Update my Grid1_UpdateCommand Event does not fire.

Can someone tell me what I'm doing wrong please?

FYI…This is what I have in my InitializeComponent so it know what event to
fire

private void InitializeComponent()
{
this.Grid1.PageIndexChanged += new
System.Web.UI.WebControls.DataGridPageChangedEvent Handler(this.Grid1_PageIndexChanged);
this.Grid1.CancelCommand += new
System.Web.UI.WebControls.DataGridCommandEventHand ler(this.Grid1_CancelCommand);
this.Grid1.EditCommand += new
System.Web.UI.WebControls.DataGridCommandEventHand ler(this.Grid1_EditCommand);
this.Grid1.SortCommand += new
System.Web.UI.WebControls.DataGridSortCommandEvent Handler(this.Grid1_SortCommand);
this.Grid1.UpdateCommand += new
System.Web.UI.WebControls.DataGridCommandEventHand ler(this.Grid1_UpdateCommand);
this.Grid1.DeleteCommand += new
System.Web.UI.WebControls.DataGridCommandEventHand ler(this.Grid1_DeleteCommand);
this.Grid1.SelectedIndexChanged += new
System.EventHandler(this.Grid1_SelectedIndexChange d);
this.btnLoadFile.Click += new System.EventHandler(this.btnLoadFile_Click);
this.btnSave.Click += new System.EventHandler(this.btnSave_Click);
this.btnCancel.Click += new System.EventHandler(this.btnCancel_Click);
this.Load += new System.EventHandler(this.Page_Load);
}

Thanks,
Oct 26 '06 #1
1 1559
SAL
It turns out when you have your column defined like my code snippet shows,
the asp:RegularExpressionValidator prevents the UpdateCommand from firing.

My UpdateCommand now works fine.

<Columns>
<asp:ButtonColumn Visible="False" Text="Select"
CommandName="Select"></asp:ButtonColumn>
<asp:TemplateColumn SortExpression="InvoiceNumber" HeaderText="Invoice
Number">
<ItemStyle CssClass="InvoiceNumber" VerticalAlign="Middle"></ItemStyle>
<ItemTemplate>
<asp:Label id="Label6" Width="100%" Text='<%#
DataBinder.Eval(Container.DataItem, "InvoiceNumber") %>' Runat="server">
</asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox id="Textbox1" Width="100%" Text='<%#
DataBinder.Eval(Container.DataItem, "InvoiceNumber") %>' Runat="server">
</asp:TextBox>
<asp:RegularExpressionValidator id="revInvoiceNumber" runat="server"
Width="100%" ControlToValidate="txtInvoiceNumber"
ValidationExpression="^[A-Z|a-z|0-9|\-]+$" ErrorMessage="Invoice Number
is incorrect"></asp:RegularExpressionValidator>
</EditItemTemplate>
</asp:TemplateColumn>
</Columns>

"SAL" wrote:
Hello,

I created a datagrid where I set the Events to there associated functions
(i.e. Grid1_UpdateCommand, etc.). All these Events I have established work
as they are suppose to except for my Grid1_UpdateCommand.

I load my datagrid via a Select query. When my DataGrid is populated I have
a column with an Edit button in it. When you Select Edit to edit the row you
want, that column changes the Edit button to an Update and Cancel button.
The Cancel works fine, but when you modify the data in that row and press
Update my Grid1_UpdateCommand Event does not fire.

Can someone tell me what I'm doing wrong please?

FYI…This is what I have in my InitializeComponent so it know what event to
fire

private void InitializeComponent()
{
this.Grid1.PageIndexChanged += new
System.Web.UI.WebControls.DataGridPageChangedEvent Handler(this.Grid1_PageIndexChanged);
this.Grid1.CancelCommand += new
System.Web.UI.WebControls.DataGridCommandEventHand ler(this.Grid1_CancelCommand);
this.Grid1.EditCommand += new
System.Web.UI.WebControls.DataGridCommandEventHand ler(this.Grid1_EditCommand);
this.Grid1.SortCommand += new
System.Web.UI.WebControls.DataGridSortCommandEvent Handler(this.Grid1_SortCommand);
this.Grid1.UpdateCommand += new
System.Web.UI.WebControls.DataGridCommandEventHand ler(this.Grid1_UpdateCommand);
this.Grid1.DeleteCommand += new
System.Web.UI.WebControls.DataGridCommandEventHand ler(this.Grid1_DeleteCommand);
this.Grid1.SelectedIndexChanged += new
System.EventHandler(this.Grid1_SelectedIndexChange d);
this.btnLoadFile.Click += new System.EventHandler(this.btnLoadFile_Click);
this.btnSave.Click += new System.EventHandler(this.btnSave_Click);
this.btnCancel.Click += new System.EventHandler(this.btnCancel_Click);
this.Load += new System.EventHandler(this.Page_Load);
}

Thanks,
Oct 26 '06 #2

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

Similar topics

13
by: Manuel Lopez | last post by:
I have a puzzling form timer problem that I didn't experience prior to Access 2003 (though I'm not sure access 2003 is to blame). Here's the situation: a computer has two access 2003 databases on...
3
by: bardo | last post by:
I have a Datagrid that is inside a panel. I want to use the keyDown event to reconize the arrow keys. But I have no luck at all. The problem is that the keydown event won't fire at all, unless I...
0
by: Ozer | last post by:
Hi guys, I need some help. In my datagrid's updatecommand event i'm trying to get textboxes values and also do it. But when i update the values in textboxes and fire the event, I can't get the...
2
by: Sam Miller | last post by:
Hi, I have a button event that won't fire. I left it on Friday and it worked fine. I came back in on Monday and it won't fire. I tried putting another button and just putting a...
2
by: Breeto | last post by:
Can anyone please tell me why the following doesn't work... using System; using System.Web; namespace AspTests {
2
by: Ryan Liu | last post by:
Hi, I need the MouseDown event be trigged everytime when you press mouse in a datagrid (System.Windows.Forms). But seems mouse event will only fire once, and it seems changed to edit mode...
5
by: wandii | last post by:
Hi, I am trying to update the customer table by using the updatecommd, please see below, however, when it runs it does not fire the update statement. I ran the sql profiler and the only...
9
by: jeff | last post by:
New VB user...developer... Situation...simplified... - I want to wrap a pre and post event around a system generated where the pre-event will always execute before the system event and the...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
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: marcoviolo | last post by:
Dear all, I would like to implement on my worksheet an vlookup dynamic , that consider a change of pivot excel via win32com, from an external excel (without open it) and save the new file into a...

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.