Posted on: 9/12/2012 1:31:12 AM | Views : 235

Hi,
1. I am exporting the gridview records into excels and pdfs, i know this codes but i dont know the explanation. How should i explain this code and what controls should use for this exports. For ex: below is my excel exporting code.

GridView GridView1 = new GridView();
GridView1.AllowPaging = false;
DataTable dt1 = new DataTable();
dt1 = GetDataTable();
GridView1.DataSource = dt1;
GridView1.DataBind();
Response.Clear();
Response.Buffer = true;
Response.AddHeader("content-disposition", "attachment;filename=DataTable.xls");
Response.ContentType = "application/ms-excel";
StringWriter sw = new StringWriter();
HtmlTextWriter hw = new HtmlTextWriter(sw);
GridView1.RenderControl(hw);
Response.Output.Write(sw.ToString());
Response.Flush();
Response.End();
...

Go to the complete details ...