Tag: global asax

尝试将数据网格导出为ex​​cel,执行到Global axax中的Application_Error

我在互联网search的人,发现很多解决scheme出口gridview到Excel。 我尝试了所有的解决scheme,但没有一个为我工作。 build议我跟踪Application_Error模块。 当debugging我的执行去 //Global.asax protected void Application_Error(object sender, EventArgs e) { Exception exc = Server.GetLastError(); } 我得到的exception是:: exception的types'System.Web.HttpUnhandledException'被抛出。 我无法弄清楚我做错了什么。 请任何人都可以build议我,发生了什么事情。 private void ExportGridToExcel() { try { Response.Clear(); Response.Buffer = true; Response.ClearContent(); Response.ClearHeaders(); Response.Charset = ""; string FileName = "PatientCount_" + DateTime.Now + ".xls"; StringWriter strwritter = new StringWriter(); HtmlTextWriter htmltextwrtter = new HtmlTextWriter(strwritter); Response.Cache.SetCacheability(HttpCacheability.NoCache); […]