Export ASP.NET to Excel

The following program shows how to export from a GridView data to an Excel file.




The RenderControl method outputs server control content to a provided HtmlTextWriter object and stores tracing information about the control if tracing is enabled.



The above method will confirms that an HtmlForm control is rendered for the specified ASP.NET server control at run time.

Somtimes you will get an exception unless you are not declared the above method in your program, the exception shows like :

System.Web.HttpException: Control GridView1 of type GridView must be placed inside a form tag with runat=server.

The following ASP.NET program load the data from database to Gridview control and then you can export the data to an Excel file.


Click the following links to see full source code

C# Source Code
VB.NET Source Code
default.aspx.vb (C) 2021    Founded by raps mk
All Rights Reserved. All other trademarks are property of their respective owners.
SiteMap  | Terms  | About