473,320 Members | 2,111 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.

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 1565
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...
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
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...
1
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...
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: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
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...

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.