hi i am developing an application where i am using a grid to dispaly data and adding a dynamic datatable as the header of the gridview and iam using the following code to export the grid view into excel but i am unable get the datatable which was added dynamically to the grid into the excel. the code i am using is:
Response.AddHeader("content-disposition", "attachment;filename=Report.xls");
Response.Charset = String.Empty;
Response.ContentType = "application/vnd.xls";
System.IO.StringWriter sw = new System.IO.StringWriter();
System.Web.UI.HtmlTextWriter hw = new HtmlTextWriter(sw);
GridView1.DataBind();
GridView1.RenderControl(hw);
Response.Write(sw.ToString());
Response.End();
is thee any other method to follow.
Thanks in advance!