This error comes when you are exporting the GridView control in the Visual Studio.NET
I got this error while exporting gridview to PDF using iTEXT.
The thing is that ASP.NET has a very strong page lifecycle. RegisterForEventValidation can only be called during the Render phase of the page lifecycle. That means it will fail when calling RenderControl() at any other moment.
However, my first focus would be on GridBuilding. If that has anything on it that can cause a PostBack, then that will have to be turned off before rendering.
RegisterForEventValidation can only be called during Render();
You can solve this error but the trick is very dirty. You have to turn the eventValidation off in order for this to work.
You can do this in the web.config file but in this case the eventValidation will be turned off for all the pages.
<pages enableEventValidation ="false" ></pages>
or Add the @Page Directive in code behind file.
EnableEventValidation ="false" <%@ Page Language="C#" AutoEventWireup="true" Debug ="true" EnableEventValidation ="false" CodeFile="Default.aspx.cs" Inherits="_Default" %>
Version: VS 2008, iTEXT, ASP.NET 3.5, C#