Hi.
I have a WebDataGrid with paging and sorting. The data is binded in the OnLoad event. EnableEventValidation for the page and the grid EnableViewState attribute are both true. If I load the page and then press the submit button it works fine. But If I navigate to another page in the grid and then press the submit button I get this error:
ArgumentException: 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.] System.Web.UI.ClientScriptManager.ValidateEvent(String uniqueId, String argument) +10973200 System.Web.UI.WebControls.DropDownList.LoadPostData(String postDataKey, NameValueCollection postCollection) +72 System.Web.UI.Page.ProcessPostData(NameValueCollection postData, Boolean fBeforeLoad) +507 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint
The error is in the DropDownList.LoadPostData but it must be related t the WebDataGrid as it only occurs when I change the page or sort some column.
Any ideas on how to fix this.
Thanks a lot.
Hello ldwedari,
This exception is normally thrown when page ViewState is modified in unusual way. What you can do is to disable event validation for the page (EnableEventValidation="false"). This is not the best approach but will most probably work in your situation - http://forums.asp.net/t/1724183.aspx/1
In order to view the actual cause for this exception you can enable/disable ViewState for the page and for the grid and other controls on the page. You can also remove dropdown control from the page and test if this exception will be present again.
If the issue persists you should create a simple example that can be run on our side and reproduces it and we will test it further.
Inform me if you have further questions.
Yes, yesterday I found the answer. It does not really had to do with the WebDataGrid but some how adding the grid made the problem appear.
The issue is that I was adding a dynamic DropDownList component to the page and I was calling DataBind() before adding the component to the page in the CreateChildControls() method.
Regards.