亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

淺析Repeater控件的使用 (原樣導(dǎo)出和動態(tài)顯示/隱藏Repeater中的列)

 更新時間:2016年12月09日 13:15:18   作者:扯  
本文主要介紹了淺析Repeater控件的使用 (原樣導(dǎo)出和動態(tài)顯示/隱藏Repeater中的列)的具體方法,需要的朋友可以看下

一、Repeater數(shù)據(jù)原樣導(dǎo)出

DataTable dt = ViewState["DtDatat"] as DataTable; //Repeater綁定的數(shù)據(jù)源
      this.Repeater1.DataSource = dt;
      this.Repeater1.DataBind();
      DisplayDetailCol(false);
      //使用流方式導(dǎo)出Excel
      HttpContext.Current.Response.ContentEncoding = System.Text.Encoding.Default;
      HttpContext.Current.Response.ContentType = "application/ms-excel";
      HttpContext.Current.Response.Charset = "gb2312";
      HttpContext.Current.Response.AppendHeader("Content-Disposition", "attachment;filename=" + Context.Server.UrlPathEncode("excel名稱.xls")); //解決中文亂碼問題
      StringWriter sw = new StringWriter();
      HtmlTextWriter htw = new HtmlTextWriter(sw);
      Repeater1.RenderControl(htw);
      HttpContext.Current.Response.Write(sw.ToString());
      HttpContext.Current.Response.End();

二、動態(tài)顯示/隱藏Repeater中的列

 foreach (RepeaterItem item in this.Repeater1.Controls)
    {
      if (item.ItemType == ListItemType.Header)
      {
        item.FindControl("panelDetail").Visible = b;
      }
      if (item.ItemType == ListItemType.Item)
      {
        item.FindControl("lbtnDetail").Visible = b;
      }
    }

三、下載的excel顯示成html格式

     需要將<table>標(biāo)簽添加到HeaderTemplate和FooterTemplate中  

四、導(dǎo)出的Excel數(shù)據(jù)為空或則數(shù)據(jù)都縮到一列

       不要設(shè)置列的寬度為百分比

以上就是本文的全部內(nèi)容,希望本文的內(nèi)容對大家的學(xué)習(xí)或者工作能帶來一定的幫助,同時也希望多多支持腳本之家!

相關(guān)文章

最新評論