This is a migrated thread and some comments may be shown as answers.

Invalid postback or callback argument with LinqDataSource

1 Answer 46 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Thomas
Top achievements
Rank 1
Thomas asked on 06 Apr 2011, 09:57 PM
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?

1 Answer, 1 is accepted

Sort by
0
Tsvetina
Telerik team
answered on 08 Apr 2011, 11:48 AM
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
Tags
Grid
Asked by
Thomas
Top achievements
Rank 1
Answers by
Tsvetina
Telerik team
Share this question
or