我需要实现的效果是点击一个页面的超链接之后跳转到另外一个页面,将查询的结果返回出来,其中跳转到的那个页面上有一个button,提供存为excel档的功能。
我将变量用sesson保存起来,在跳转到的页面中的page_load中将需要的数据处理出来
 if (!IsPostBack)
        {
            try
            {
                cell.Impl.CellDefectInfo Condition = (cell.Impl.CellDefectInfo)Session["_parameterInfo"];
                int flag = int.Parse(Session["flag"].ToString());
                GetDetailData(ref Condition, ScrapDetailGv, flag);
            }
            catch (Exception ex)
            {
                ex.ToString();
            }
        }
这些都可以实现,但是当我点页面的存为excel档的时候就挂了,我将page_load设了断点,好像点button的时候根本就没有跑page_load就直接死掉了The page cannot be displayed 
The page you are looking for is currently unavailable. The Web site might be experiencing technical difficulties, or you may need to adjust your browser settings. --------------------------------------------------------------------------------Please try the following:Click the  Refresh button, or try again later.If you typed the page address in the Address bar, make sure that it is spelled correctly.To check your connection settings, click the Tools menu, and then click Internet Options. On the Connections tab, click Settings. The settings should match those provided by your local area network (LAN) administrator or Internet service provider (ISP). 
See if your Internet connection settings are being detected. You can set Microsoft Windows to examine your network and automatically discover network connection settings (if your network administrator has enabled this setting). 
Click the Tools menu, and then click Internet Options. 
On the Connections tab, click LAN Settings. 
Select Automatically detect settings, and then click OK. 
Some sites require 128-bit connection security. Click the Help menu and then click About Internet Explorer to determine what strength security you have installed. 
If you are trying to reach a secure site, make sure your Security settings can support it. Click the Tools menu, and then click Internet Options. On the Advanced tab, scroll to the Security section and check settings for SSL 2.0, SSL 3.0, TLS 1.0, PCT 1.0. 
Click the  Back button to try another link. 
 
我完全不知道怎么一回事,请高手指点一下,这个问题好奇怪啊。

解决方案 »

  1.   

    下面那一部分是在IIS中Debug点存为Excel时出现的,我不知道什么意思,以前没有遇到过
      

  2.   

    if (!IsPostBack)
            {
                try
                {
                    cell.Impl.CellDefectInfo Condition = (cell.Impl.CellDefectInfo)Session["_parameterInfo"];
                    int flag = int.Parse(Session["flag"].ToString());
                    GetDetailData(ref Condition, ScrapDetailGv, flag);
                }
                catch (Exception ex)
                {
                    ex.ToString();
                }
            } 你这个是在IsPostBack里  点按钮当然不会执行这里面的代码。。IsPostBack 是第一次加载   你以后点按钮怎么会触发这个了
      

  3.   

    我就是要第一次加载的时候把数据处理出来,然后呈现在gridview(ScrapDetailGv)上,然后点存为Excel将其存为excel, 当Gv数据出来之后点btn就死掉了,我尝试了一下,如果将gv的viewstate设置为false就可以跑进btn的方法里,如果设置为true就直接死掉了。但是查到的一些方法都是传一个gv,类似于
     protected void Export(string FileType, string FileName)//把数据从Gridview导出到excel的方法
        {
            Response.AppendHeader("Content-Disipostion", "attachment;filename=" + HttpUtility.UrlEncode(FileName, System.Text.Encoding.Default).ToString());
            Response.ContentType = FileType;
            this.EnableViewState = false;
            StringWriter tw = new StringWriter();
            HtmlTextWriter hw = new HtmlTextWriter(tw);
            ScrapDetailGv.RenderControl(hw);
            Response.Write(tw.ToString());
            Response.End();
        }
    如果设为false就基本上没有办法存为一个excel档了
      

  4.   

    是导出为excel啊??老兄遇到过吗??