如题:
在一个框架,左侧是功能链接,右侧对应的是相应的页面,现在在右侧点击'导出'按钮,保存完EXCEL文件后,再点击左侧的其它功能链接,则没反应,打不开.也没提示.
DataGrid导出EXCEL的代码如下:
Response.Clear(); 
Response.Buffer= true; 
Response.Charset="GB2312";    
Response.AppendHeader("Content-Disposition","attachment;filename=FileName.xls"); 
Response.ContentEncoding=System.Text.Encoding.GetEncoding("GB2312");//设置输出流为简体中文
Response.ContentType = "application/ms-excel";//设置输出文件类型为excel文件。 
this.EnableViewState = false;    
System.Globalization.CultureInfo myCItrad = new System.Globalization.CultureInfo("ZH-CN",true);
System.IO.StringWriter oStringWriter = new System.IO.StringWriter(myCItrad); 
System.Web.UI.HtmlTextWriter oHtmlTextWriter = new System.Web.UI.HtmlTextWriter(oStringWriter);
this.ClearControls(DataGrid1);
this.DataGrid1.RenderControl(oHtmlTextWriter); 
Response.Write(oStringWriter.ToString());
Response.End();

解决方案 »

  1.   

    不跟上面这段代码有关,应该跟按钮的回送机制有关,也就是IsPostBack的问题。
      

  2.   

    我觉得也不是代码的问题,但我的Page_Load中只有以下代码.不知是怎么回事.
    if (!IsPostBack)
    {
    string sql="select code,dwf_name from dwfinanceins where jc=2";  //金融机构
    DropDownList1.DataSource=mydata.dbbind(sql);
    DropDownList1.DataTextField="dwf_name";
    DropDownList1.DataValueField="code";
    DropDownList1.DataBind();
    DropDownList1.Items.Insert(0,new System.Web.UI.WebControls.ListItem("请选择单位","请选择单位"));
    }
      

  3.   

    可能是用了Response.End();这句话之后,页面的连接就失效了。
      

  4.   

    樓上有理,要把Response.End();去掉
      

  5.   

    我也遇到了问题:
    左边点击URL后,有边打开A,
    A页面输入日期和部门后,点击导出按钮Response.Redirect到b页面,b页面根据A传递过来的日期部门参数导出到EXCELL.每次导出成功后,左边的该连接也不能用了,IE提示有错误.我这里应该不是Response.End()的原因吧.最后改成JS的open()可以导出了,以前的问题也没有了.但会打开一个空的窗口b.而且有可能被客户屏蔽的,那样就导不出了.
    -----------
    private void Button1_Click(object sender, System.EventArgs e)
    {
    Page.RegisterClientScriptBlock("output","<script>window.open( 'TraceOutToExcel.aspx?start_time="+startTime.Value.ToString()+"&end_time="+endTime.Value.ToString()+"')</script>");
    }
      

  6.   

    应该不是Response.End();原因,我去了不行.有没有好的解决方法?
      

  7.   

    问导出到Excel之后出问题的有点多哈。
    我用下面的方法解决的
    http://community.csdn.net/Expert/topic/4339/4339412.xml?temp=.8470728