471,595 Members | 1,913 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,595 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 1479
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 discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by bardo | last post: by
2 posts views Thread by Sam Miller | last post: by
5 posts views Thread by wandii | last post: by
9 posts views Thread by jeff | last post: by
reply views Thread by leo001 | last post: by
reply views Thread by Anwar ali | last post: by

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.