Button in GridView causes Invalid postback or callback argument

Discussion in 'ASP .Net Datagrid Control' started by dev648237923, Dec 28, 2006.

  1. dev648237923

    dev648237923 Guest

    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.
    dev648237923, Dec 28, 2006
    #1
    1. Advertising

  2. dev648237923

    dev648237923 Guest

    OK I fixed it --
    It had to do with when I did databinding

    "dev648237923" <> wrote in message
    news:...
    > 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.
    >
    dev648237923, Dec 28, 2006
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. JULO
    Replies:
    1
    Views:
    6,401
    ketanbece
    Oct 29, 2008
  2. =?Utf-8?B?RGFiYmxlcg==?=
    Replies:
    0
    Views:
    804
    =?Utf-8?B?RGFiYmxlcg==?=
    Apr 20, 2006
  3. Mark Rae [MVP]
    Replies:
    0
    Views:
    434
    Mark Rae [MVP]
    Aug 30, 2007
  4. Mufasa
    Replies:
    1
    Views:
    630
    Mufasa
    Aug 31, 2007
  5. Iain
    Replies:
    1
    Views:
    1,902
    Alexey Smirnov
    Nov 23, 2009
Loading...

Share This Page