导出是将分页属性改为false,还有一种办法转换分页按钮控件,代码太长,asp.net网站上有,你去找一下

解决方案 »

  1.   

    我在导出时重新绑定一个新的dataset搞定的
      

  2.   

    导出时改成分页属性 :false ,执行网上流传的那个代码转成excel ,完成后再让分页属性为true!
      

  3.   

    littlehb(网际浪子):你說的"网上流传的那个代码",你有沒有呀.可以給我嗎?這覺得我的這個代碼不是很好.謝謝.
      

  4.   

    public void ToExcel(System.Web.UI.Control ctl)  
    {
    // HttpContext.Current.Response.Charset ="GB2312";
    HttpContext.Current.Response.Charset ="";
    HttpContext.Current.Response.AppendHeader("Content-Disposition","attachment;filename=money.xls");

    HttpContext.Current.Response.ContentEncoding =System.Text.Encoding.GetEncoding("GB2312"); 
    HttpContext.Current.Response.ContentType ="application/ms-excel";//image/JPEG;text/HTML;image/GIF;vnd.ms-excel/msword
    ctl.Page.EnableViewState =false;
    System.IO.StringWriter  tw = new System.IO.StringWriter() ;
    System.Web.UI.HtmlTextWriter hw = new System.Web.UI.HtmlTextWriter (tw);
    ctl.RenderControl(hw);
    HttpContext.Current.Response.Write(tw.ToString());
    HttpContext.Current.Response.End();
    }
    用法:ToExcel(DataGrid1);