you need to:
1. Get Data from gridview
2. Supply it to the target system(i.e. pdf, word or excel) in their formats.
Check the below example to export it to excel
private void ExportToExcel()
StringWriter stringWriter = new StringWriter();
HtmlTextWriter htw = new HtmlTextWriter(stringWriter);
Response.Charset = "";
Response.ContentType = "application/vnd.xls";
DataTable dt = new DataTable();
DataRow dr = dt.NewRow();
dr["Col"] = "some value";
GridView GridView1 = new GridView();
GridView1.DataSource = dt;
catch (Exception ex)
you can change the content type to Word if you want to export it to word.
There are lots of tutorial providing information on how to create PDF from a html with iTextSharp. like:
so create a pdf from the html returned from stringwriter and write it to the output of response with proper contenttype.
Things to remember:
Gridview1.RenderControl(..) will throw an exception if GridView1 is added to the web page you must create gridview on the fly.
hope this will help.