Error :-
When i was going to export excel from grid view in .Net i was faced this error "Control 'GridView1' of type 'GridView' must be placed inside a form tag with runat=server."
Solution :-
Code behind confirmed it that you indeed are exporting your grid.
The above exception occurs when one tries to export a GridView control to Word, Excel, PDF, CSV or any other formats. Here the .net compiler thinks that the control is not added to the form and is rendered, hence it throws this error even if your GridView control is inside a form with runat = “server”.
You have to tell the compiler that the control is rendered explicitly by overriding theVerifyRenderingInServerForm event.
Like:
The above exception occurs when one tries to export a GridView control to Word, Excel, PDF, CSV or any other formats. Here the .net compiler thinks that the control is not added to the form and is rendered, hence it throws this error even if your GridView control is inside a form with runat = “server”.
You have to tell the compiler that the control is rendered explicitly by overriding theVerifyRenderingInServerForm event.
Like:
public override void VerifyRenderingInServerForm(Control control) { //Confirms that an HtmlForm control is rendered for the specified ASP.NET server control at run time. }
This will confirms that an HtmlForm control is rendered for the specified ASP.NET server control at run time.
No comments:
Post a Comment