public void ExportDetails() { SqlConnClass connClass = new SqlConnClass(); DataTable dt = connClass.GetQrCodeDetails(); GridView gv = new GridView(); gv.AutoGenerateColumns = false; BoundField ID = new BoundField(); ID.HeaderText = "ID"; ID.DataField = "ID"; gv.Columns.Add(ID); BoundField QRIMAGE = new BoundField(); IMAGE.HeaderText = "IMAGE"; IMAGE.DataField = "IMAGE"; gv.Columns.Add(IMAGE); StreamWriter sw = new StreamWriter(); //Error is showing in this line. HtmlTextWriter htw = new HtmlTextWriter(sw); gv.RenderControl(htw); Response.Write(htw); ExportTableData(sw.ToString()); } public void ExportTableData(string data) { string attach = "attachment;filename=CodeDetails.xls"; Response.ClearContent(); Response.AddHeader("content-disposition", attach); Response.ContentType = "application/ms-excel"; Response.Write(data); Response.End(); }
please help me.How to resolve this error.Thanks in Advance.Ankit AgarwalSoftware Engineer