user682417
user682417

Reputation: 1518

Exporting grid view data to pdf

I want to export the data from gridview to pdf, I have got the error like this while exporting

Exception Details: System.InvalidOperationException: RegisterForEventValidation can only be called during Render();

And this is my code

GridView1.AllowPaging = false;
GridView1.DataBind();  
GridView1.RenderControl(tx);
GridView1.HeaderRow.Style.Add("width", "15%"); 
GridView1.HeaderRow.Style.Add("font-size", "10px");

it was showing error at Gridview1.RenderConrol(tx). tx is coming from this statement:

HtmlTextWriter tx = new HtmlTextWriter(sw);

can any one help me

many thanks

Upvotes: 0

Views: 636

Answers (1)

Leon
Leon

Reputation: 3401

You're modifying the control AFTER it was rendered. Could this be what is firing this "RegisterForEventValidation" event?

Upvotes: 1

Related Questions