WEBFORM 中DataGrid导到Excel后,原页面内其他链接都无效了
不知道怎么回事,我好几个项目都遇到这个问题,求救大虾啊!
谢了我采用的是这个方法
this.Response.Clear();
this.Response.Buffer= true;
this.EnableViewState = false;
strFileName = System.Web.HttpUtility.UrlEncode(System.Text.Encoding.UTF8.GetBytes(strFileName)) + ".xls"; this.Response.ContentType = "application/vnd.ms-excel";
this.Response.ContentEncoding = System.Text.Encoding.GetEncoding("GB2312");
this.Response.AppendHeader("Content-Disposition", "attachment;filename=" + strFileName); System.IO.StringWriter oStringWriter = new System.IO.StringWriter();
System.Web.UI.HtmlTextWriter oHtmlTextWriter = new System.Web.UI.HtmlTextWriter(oStringWriter);
dgdOut.RenderControl(oHtmlTextWriter);
Response.Write(oStringWriter.ToString());
Response.Flush();
Response.Close();