一个关于数据导出的问题 希望哪位大侠能帮帮我谢谢了
我在页面上放了一个repeater控件,这个repeater在updatepanel中,我在后台对数据进行了绑定。
protected void exportData_Click(object sender, EventArgs e)
{
System.Globalization.CultureInfo myCItrad = new System.Globalization.CultureInfo("ZH-CN", true);
System.IO.StringWriter stringwriter = new System.IO.StringWriter(myCItrad);
System.Web.UI.HtmlTextWriter htmltextWriter = new HtmlTextWriter(stringwriter);
this.ceshi.EnableViewState = false;
this.ceshi.RenderControl(htmltextWriter);
Response.Clear();
Response.Buffer = true;
Response.ContentType = "application/ms-txt";
Response.Charset = "GB2312";
this.ceshi.Page.EnableViewState = true;
Response.AppendHeader("Content-Disposition", "online;filename=miller.txt");
Response.ContentEncoding = System.Text.Encoding.GetEncoding("GB2312");
Response.Write(stringwriter.ToString());
Response.Flush();
Response.End();
}
是这样的,但是我点击导出之后也没报错,就是没有看见导出的文件miller.txt,我昨天在搜索的时候发现这些文件页面文件都在缓存中,
这是那些网页缓冲文件的属性
http://www.google.cn/complete/search?hl=zh-CN&pq=Response.AppendHeader(%22Content-Disposition%22%2C%20%22attachment%3Bfilename%3Dmiller.xls%22)%3B&xhr=t&q=%E5%B0%86%E6%95%B0%E6%8D%AE%E6%BA%90%E5%AF%BC%E5%87%BA%E5%88%B0exc&cp=1