Button in GridView causes Invalid postback or callback argument

D

dev648237923

In my GridView I have a button in the Footer. When I click it it causes:

Invalid postback or callback argument. Event validation is enabled using
<pages enableEventValidation="true"/> in configuration or <%@ Page
EnableEventValidation="true" %> in a page. For security purposes, this
feature verifies that arguments to postback or callback events originate
from the server control that originally rendered them. If the data is valid
and expected, use the ClientScriptManager.RegisterForEventValidation method
in order to register the postback or callback data for validation.

If I change it to a LinkButton it does not cause the error???

See below I have a LinkButton and a Button -- the Button causes the error
while the LinkButton is fine -- odd???

------
There is nothing on the page except for the grid:

<asp:GridView ID="gvAlias" runat="server"
AutoGenerateColumns="False" CssClass="Font8"
ShowFooter="True"
OnRowDataBound="gvAlias_RowDataBound"
OnRowCancelingEdit="gvAlias_RowCancelingEdit"
OnRowCommand="gvAlias_RowCommand"
OnRowDeleting="gvAlias_RowDeleting"
OnRowEditing="gvAlias_RowEditing"
OnRowUpdating="gvAlias_RowUpdating"<Columns>
<asp:TemplateField ShowHeader="False" ItemStyle-CssClass="Font8">
<ItemTemplate>
<asp:LinkButton ID="lbEdit" runat="server" CausesValidation="False"
CommandName="Edit" Text="Edit" />
<asp:LinkButton ID="lbDelete" runat="server" CausesValidation="False"
CommandName="Delete" Text="Delete" />
</ItemTemplate>
<EditItemTemplate>
<asp:LinkButton ID="lbUpdate" runat="server" CausesValidation="True"
CommandName="Update" Text="Update" />
<asp:LinkButton ID="lbCancel" runat="server" CausesValidation="False"
CommandName="Cancel" Text="Cancel" />
</EditItemTemplate>
<FooterTemplate>
<asp:Button ID="lbInsert" text="New" font-size="8pt" runat="server"
CausesValidation="False" CommandName="Insert" CssClass="Font8" />
<asp:LinkButton ID="bInsert" text="New" font-size="8pt" runat="server"
CausesValidation="False" CommandName="Insert" CssClass="Font8" />
</FooterTemplate>
</asp:TemplateField>

<asp:BoundField DataField="ID" HeaderText="" ReadOnly="true"
HeaderStyle-CssClass="hidetd" FooterStyle-CssClass="hidetd"
ItemStyle-CssClass="hidetd" />
....

------
Code-behind:

protected void gvAlias_RowCommand(object sender, GridViewCommandEventArgs e)
{
if (e.CommandName == "Insert")
{
...
}
.....

Thank you for any ideas.
 

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,755
Messages
2,569,534
Members
45,008
Latest member
Rahul737

Latest Threads

Top