By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
445,926 Members | 1,820 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 445,926 IT Pros & Developers. It's quick & easy.

UpdateCommand Event won't fire

P: n/a
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
Share this Question
Share on Google+
1 Reply


P: n/a
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.