sweetwater
New Member
On my aspx page, I have a \[code\]Usercontrol\[/code\] which contains a \[code\]Gridview\[/code\], whose data is loaded dynamically based on params passed from the aspx page to the UserControl, which I called \[code\]QuotesReport1\[/code\].When the export runs, it only exports the layout into the \[code\]Spreadsheet\[/code\], and none of the gridview's data, for example:\[code\]<style> body { margin: 0px; }</style><div></div>\[/code\]My code for the export is:\[code\]protected void Page_Load(object sender, EventArgs e){ string toDate = ""; string fromDate = ""; toDate = Request.QueryString.Get("toDate"); fromDate = Request.QueryString.Get("fromDate"); QuotesReport1.ToDate = DateTime.Parse(toDate); QuotesReport1.FromDate = DateTime.Parse(fromDate); QuotesReport1.Status = QuotesReport.quoteStatus.PENDING_REVIEW; string attachment = "attachment; filename=Quotes_Pending.xls"; Response.ClearContent(); Response.AddHeader("content-disposition", attachment); Response.ContentType = "application/ms-excel"; StringWriter sw = new StringWriter(); HtmlTextWriter htw = new HtmlTextWriter(sw); QuotesReport1.RenderControl(htw); Response.Write(sw.ToString()); Response.End();}public override void VerifyRenderingInServerForm(Control control) { }\[/code\]Inside the UserControl, a SQL query runs, which returns a DataTable, which is then bound to the Gridview inside the UserControl, something along the lines of:\[code\]SQLData da = new SQLData();GridView1.DataSource = da.SGetDataTable(query);GridView1.DataBind();\[/code\]