UpdateCommand Event won't fire

G

Guest

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.DataGridPageChangedEventHandler(this.Grid1_PageIndexChanged);
this.Grid1.CancelCommand += new
System.Web.UI.WebControls.DataGridCommandEventHandler(this.Grid1_CancelCommand);
this.Grid1.EditCommand += new
System.Web.UI.WebControls.DataGridCommandEventHandler(this.Grid1_EditCommand);
this.Grid1.SortCommand += new
System.Web.UI.WebControls.DataGridSortCommandEventHandler(this.Grid1_SortCommand);
this.Grid1.UpdateCommand += new
System.Web.UI.WebControls.DataGridCommandEventHandler(this.Grid1_UpdateCommand);
this.Grid1.DeleteCommand += new
System.Web.UI.WebControls.DataGridCommandEventHandler(this.Grid1_DeleteCommand);
this.Grid1.SelectedIndexChanged += new
System.EventHandler(this.Grid1_SelectedIndexChanged);
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,
 
G

Guest

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>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,756
Messages
2,569,535
Members
45,008
Latest member
obedient dusk

Latest Threads

Top