Hi! I have a .Net webpage that displays data in some datagrids populated
based on user search criteria. There is a button, that when clicked, the
data is exported to excel. For one user, I am seeing that it works
correctly the first time he tries the report, but if he reruns the
result set or even picks a different report, the web page itself is
exported to excel and not the data. He has the same Excel version as
others (Excel 2003) who are not able to recreate the issue. No errors
are sent to the client.
Has anyone ever seen this? Here's the code:
private void btnExport_Click(object sender, System.EventArgs e)
{
Response.Clear();
Response.Buffer= true;
Response.ContentType = "application/vnd.ms-excel";
Response.Charset = "";
this.EnableViewState = false;
System.IO.StringWriter oStringWriter = new System.IO.StringWriter();
System.Web.UI.HtmlTextWriter oHtmlTextWriter = new
System.Web.UI.HtmlTextWriter(oStringWriter);
oHtmlTextWriter.Write("Overall Total Number of Searches: "
+lblTotSearches.Text);
oHtmlTextWriter.Write("<br>");
dgOrg.RenderControl(oHtmlTextWriter);
oHtmlTextWriter.Write("<br>");
dgFuncArea.RenderControl(oHtmlTextWriter);
oHtmlTextWriter.Write("<br>");
dgBodyArea.RenderControl(oHtmlTextWriter);
Response.Write(oStringWriter.ToString());
Response.End();
}
Thanks!!
Liz
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!