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.
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.