Invalid postback or callback argument with LinqDataSource

2 posts, 0 answers
  1. Thomas
    Thomas avatar
    143 posts
    Member since:
    Feb 2007

    Posted 06 Apr 2011 Link to this post

    I have a grid akin to the following which has as its DataSourceID a LinqDataSource:

    <telerik:RadGrid ID="MyGrid" runat="server"
        AllowAutomaticInserts="false"
        AllowFilteringByColumn="true"
        AllowSorting="true"
        PageSize="15"
        ShowFooter="true"
        EnableLinqExpressions="true"
        OnUpdateCommand="MyGrid_UpdateCommand"
        OnItemDataBound="MyGrid_ItemDataBound"
        DataSourceID="MyLinqDataSource"
        >
        <PagerStyle Mode="NextPrevNumericAndAdvanced" />
        <MasterTableView AutoGenerateColumns="false" EditMode="InPlace"
            AllowFilteringByColumn="true"
            DataKeyNames="Id"
            OverrideDataSourceControlSorting="true"
            Width="1700px" TableLayout="Fixed"
            CommandItemDisplay="Top"
            >
            <CommandItemTemplate>
                <asp:Button ID="SearchButton" runat="server" Text="Search" Width="100px" Height="2em"
                    CommandName="<%=RadGrid.FilterCommandName %>" />
            </CommandItemTemplate>
            <Columns>
                ...
            </Columns>
        </MasterTableView>
        <ClientSettings AllowColumnsReorder="true" >
            <Resizing AllowColumnResize="true" AllowResizeToFit="true" EnableRealTimeResize="true" />
        </ClientSettings>
    </telerik:RadGrid>

    All columns have AutoPostBackOnFilter="false" and have a SortExpression. Whenever I click the button in the CommandItemTemplate I get the following error:

    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.

    For those that answer with "use Advanced Binding", how do I replicate all the functionality of the LinqDataSource in code-behind?
  2. Tsvetina
    Admin
    Tsvetina avatar
    1876 posts

    Posted 08 Apr 2011 Link to this post

    Hi Thomas,

    I answered you in the formal support ticket that you have opened on that matter. I am also posting the answer here for other to see, but if you have any further concerns, let us continue posting in the formal support thread.

    You do not need to switch to advanced data-binding. Filtering with a LinqDataSource and RadGrid works out-of-the-box, as you can see in this online demo.

    The problem should be caused by something else in the grid setup. As you probably know, this exception is thrown when a postback/callback is fired by an event which is not expected by the Runtime. My first suggestion is that this is related to the Filter command button.

    In order to confirm if this is the problem, you can check if the error will go away if you:
    -Set a custom command name to the button
    -In item command, on this command name, access the grid filtering items (this can be done by using the GetItems(itemType) method) and fire filtering commands for the ones you want.

    Kind regards,
    Tsvetina
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top