GridView update and cancel buttons fire RowCommand with Edit button as CommandSource

GridView update and cancel buttons fire RowCommand with Edit button as CommandSource

Post by Marco Lied » Thu, 09 Nov 2006 21:17:30

Hi folks,

When I click on a update or cancel button the wrong event is fired to
my RowCommand event handler.

My Gridview code (shown down under) uses a CommandField with
ShowEditButtonset to true.

Strange thing is that when I use AutoGenerateEditButton="true" and
remove my CommandField, the cancel button work fine and the update
button still fires the edit event to my RowCommand event handler
(instead of the update event which would be normal for a update

I made a simple sample with only the GridView and it works fine
(updating the DB like I wanted)!

I am using the 180 day trial version of VS.NET 2005 and my GridView
control is inside a usercontrol which is inside a contentpage. Can
there be a problem with ViewState (which does not remember the Update
button who is being places after clicking the Edit button) and how can
I check on this? I hoped that everything would be automaticly
intuitive, but I seem to struggle with the GridView (maybe my problem
is on a different level then the GridView alone ...)! My previous post
is also strange and I think it is connected to this one.

Are there any experts who can give me a clue?

thanks for the help, Marco

<asp:GridView ID="GridView1" runat="server"
DataSourceID="SqlDataSource1" DataKeyNames="MutaP_StartDate"
AutoGenerateColumns="False" AllowPaging="true" AllowSorting="true"
CellPadding="4" ForeColor="#333333" GridLines="None"
OnRowCommand="GridView1_RowCommand" OnRowEditing="GridView1_RowEditing"
<asp:BoundField HeaderText="StartDatum"
DataField="MutaP_StartDate" ReadOnly="true" />
<asp:BoundField HeaderText="Waarde"
DataField="MutaP_Value" />
<asp:BoundField HeaderText="Omschrijving "
DataField="MutaP_Description" />
<asp:BoundField HeaderText="Gewijzigd"
DataField="MutaP_ChangeTime" ReadOnly="true" />
<asp:CommandField ButtonType="Button"
<HeaderStyle BackColor="#333399" ForeColor="#FFFFFF"
Font-Bold="True" />
<RowStyle BackColor="#CCCCCC" />
<PagerStyle BackColor="#333399" ForeColor="#FFFFFF"
HorizontalAlign="Center" />

1. GridView ButtonField RowCommand Image/Button problem

2. GridView RowCommand Not Firing

I have a gridview that I bind to a List(of Type) at runtime.
Not using a datasource control.
The gridview has a template column with an imagebutton whose commandname is
set to 'Delete'.
The footer template has an commandbutton with the commandname set to
Both buttons cause postback, however the RowCommand event does not fire.

How can I get the rowcommand to fire?


Email: discuss at adhdata dot com

3. RowCommand Event only fires for the first row in GridView

4. GridView RowCommand event not firing!!

5. GridView.RowCommand Event fires twice

6. If I have a gridview with edit buttons, how do I show dropdowns in edit mode?

7. GridView RowCommand problem: GridView Nested in Repeater

8. Custom GridView with Button - Click Event Not Firing

9. dropdownlist inside a gridview with Edit,Update,Cancel

10. Gridview - Edit,Update,Cancel doesn't work

11. Update and Cancel events fire as Edit

12. Datagrid Update and Cancel events fire as Edit

13. Cancel button on [Enter] key press does not fire

14. Cancel button needs two clicks after validators have fired

15. Apply, cancel, ok buttons not firing