RadGrid & NeedDatasource Absurd behavior - Viewstate=false & Item/Delete Command Event Handlers

2 posts, 0 answers
  1. Zepp
    Zepp avatar
    4 posts
    Member since:
    Aug 2015

    Posted 20 Aug 2015 Link to this post

    I have wasted almost 20 hours over this. 

    My grid was not binding data when I used NeedDataSource. When I used Basic DataBinding on PageLoad/PreRender, My Item command event fired, but Delete Command event handler didn't and showed this error:

    "" Uncaught Sys.WebForms.PageRequestManagerServerErrorException: Sys.WebForms.PageRequestManagerServerErrorException: Invalid postback or callback argument. ​
    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 that I had to use NeedDataSource as I read on forum that we need to use NeedDataSource for that. When I used NeedDataSource my grid didnt show any data.

    My grid is in a RadTabStrip. At first when the page is loaded, the grid tab is not selected. However the NeedDataSource executes & sets DataSource to null because a reuired queryString value is not present on first page load. Then I append a queryString value and press enter, again NeedDataSource gets called & this time binds the grid with the queryString parameter, however the RadTabstrip that contains the grid is still not selected and some other tab is selected on page load. Now when select the tab that contains the grid, NeedDataSource doesnt get called, and there s nothing in place of the grid (The grid is not bound to any data).  


    I wasted so many office hours on this, but to no avail. I created a separate sample project for you to assess, however the issue did not occur in that sample. And trust me when I say this, I replicated each and everything in that sample, each and every property was exactly the same as was in my initial project, but in the sample the Grid showed data, I even replicated the RadTabStrip process to ensure that the events get called in exactly that same manner.


    The Soultion:

    Just 5 minutes ago I set MasterTableView's EnableViewState property to false. This solved the problem, Grid gets bond with data, NeedDataSoruce gets called everytime, Delete & Item Command event handler execute just fine. BUT in my sample project, I did not set EnableViewState=false of MasterViewTable tag. 

    Why wasnt the issue replicated in that project & why is this absurd behavior happening? Too much time wasted for just a petty issue, setting one property made it work in one project, however in another project the issue didnt occur at all. What is the possible reason kindly elaborate. What is the drawback of using EnableViewState = false of masterViewTable other than hitting the DB every time & is there any other way than setting ViewState to false.




  2. Kostadin
    Kostadin avatar
    1733 posts

    Posted 25 Aug 2015 Link to this post

    Hi Zepp,

    I am afraid based on the provided information will be hard to pinpoint the reason for that behavior. Could you please send your code declaration and the related code behind in order to observer the issue locally? This way we can try to replicate the issue and track down the cause for it.

    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 Feedback Portal and vote to affect the priority of the items
Back to Top