M
Marco Liedekerken
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
button).
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"
OnRowCancelingEdit="GridView1_RowCancelingEdit"
OnRowCommand="GridView1_RowCommand" OnRowEditing="GridView1_RowEditing"
OnRowUpdated="GridView1_RowUpdated"
OnRowUpdating="GridView1_RowUpdating">
<Columns>
<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"
ShowEditButton="true"/>
</Columns>
<HeaderStyle BackColor="#333399" ForeColor="#FFFFFF"
Font-Bold="True" />
<RowStyle BackColor="#CCCCCC" />
<PagerStyle BackColor="#333399" ForeColor="#FFFFFF"
HorizontalAlign="Center" />
</asp:GridView>
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
button).
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"
OnRowCancelingEdit="GridView1_RowCancelingEdit"
OnRowCommand="GridView1_RowCommand" OnRowEditing="GridView1_RowEditing"
OnRowUpdated="GridView1_RowUpdated"
OnRowUpdating="GridView1_RowUpdating">
<Columns>
<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"
ShowEditButton="true"/>
</Columns>
<HeaderStyle BackColor="#333399" ForeColor="#FFFFFF"
Font-Bold="True" />
<RowStyle BackColor="#CCCCCC" />
<PagerStyle BackColor="#333399" ForeColor="#FFFFFF"
HorizontalAlign="Center" />
</asp:GridView>