Gridview分页在导出后不起作用

时间:2014-10-15 00:32:53

标签: asp.net gridview

我有一个允许分页和排序的gridview,我将其导出到excel文件,如下所示。

Response.Clear();    
Response.Buffer = true;    
string filename="GridViewExport_"+DateTime.Now.ToString()+".xls";        
Response.AddHeader("content-disposition",    
"attachment;filename="+filename);    
Response.Charset = "";    
Response.ContentType = "application/vnd.ms-excel";   
StringWriter sw = new StringWriter();
HtmlTextWriter hw = new HtmlTextWriter(sw);
GridView1.AllowPaging = false;
GridView1.AllowSorting = false;
GridView1.DataBind();    
GridView1.RenderControl(hw);    
Response.Write(style);
Response.Output.Write(sw.ToString());
GridView1.AllowPaging = true;
GridView1.AllowSorting = true;
GridView1.DataBind();
Response.Flush();
Response.End();

导出后,分页和行命令不起作用。当我单击页面索引或行中的链接时,将再次下载excel文件。任何人都可以建议如何解决这个问题吗?

感谢。

0 个答案:

没有答案