乡下人产国偷v产偷v自拍,国产午夜片在线观看,婷婷成人亚洲综合国产麻豆,久久综合给合久久狠狠狠9

  • <output id="e9wm2"></output>
    <s id="e9wm2"><nobr id="e9wm2"><ins id="e9wm2"></ins></nobr></s>

    • 分享

      DataList分頁(yè)之通用類

       二寶么么噠 2010-12-27
      using System;
      using System.Data;
      using System.Configuration;
      using System.Web;
      using System.Web.Security;
      using System.Web.UI;
      using System.Web.UI.WebControls;
      using System.Web.UI.WebControls.WebParts;
      using System.Web.UI.HtmlControls;
      using System.Collections;
      using System.Collections.Generic;
      /// <summary>
      /// DataListPager 的摘要說(shuō)明
      /// </summary>
      public class DataListPager<T>
      {
       public DataListPager()
       {
        //
        // TODO: 在此處添加構(gòu)造函數(shù)邏輯
        //
          }
          #region 常用分頁(yè)
          public static string GetPageNum(IList<T> list, DataList DataListName, int PageSize)
          {
              int Page = 0, AllPage = 0, Next = 0, Pre = 0, StartCount = 0, EndCount = 0;
              string PageStr = "", QueryStr = "";
              string[] Temp_Arr = null;
              string FilePath = HttpContext.Current.Request.CurrentExecutionFilePath;
              string currentPath = HttpContext.Current.Request.Url.Query;
              //string SelPage = "  轉(zhuǎn)到<select name=SelPage id=SelPage onchange=\"javascript:location.href=this.value\">";
              int startIndex = currentPath.IndexOf("&");
              int startIndex2 = currentPath.IndexOf("=");
              if (startIndex < 0 && startIndex2 < 0) { QueryStr = "?"; }
              if (startIndex < 0)
              {
                  //QueryStr = "?";
                  if (startIndex2 > 0)
                  {
                      Temp_Arr = currentPath.Split('=');
                      if (Temp_Arr[0] != "?Page")
                      {
                          QueryStr = "";
                          QueryStr = Temp_Arr[0] + "=" + Temp_Arr[1] + "&";
                      }
                      else
                      { QueryStr = "?"; }
                  }
              }
              else
              {
                  string Temp = null;
                  string[] Params_Array = null;
                  string[] nameValues = currentPath.Split('&');
                  QueryStr = "";
                  Temp = "";
                  foreach (string param in nameValues)
                  {
                      if (param.IndexOf("=") > 0)
                      {
                          Params_Array = param.Split('=');
                          if (Params_Array[0] != "Page")
                          {
                              Temp += Params_Array[0] + "=" + Params_Array[1] + "&";
                          }
                      }
                  }
                  QueryStr = Temp;
              }
              PagedDataSource ObjPds = new PagedDataSource();
              ObjPds.DataSource = list;
              ObjPds.AllowPaging = true;
              int Total = list.Count;
              ObjPds.PageSize = PageSize;
              if (HttpContext.Current.Request.QueryString["Page"] != null)
              {
                  Page = Convert.ToInt32(HttpContext.Current.Request.QueryString["Page"]);
              }
              else
              {
                  Page = 1;
              }
              ObjPds.CurrentPageIndex = Page - 1;
              DataListName.DataSource = ObjPds;
              DataListName.DataBind();
              if (Page < 1) Page = 1;
              if (PageSize != 0)
              {
                  AllPage = (Total / PageSize);
                  AllPage = ((Total % PageSize) != 0 ? AllPage + 1 : AllPage);
                  AllPage = (AllPage == 0 ? 1 : AllPage);
              }
              Next = Page + 1;
              Pre = Page - 1;
              StartCount = (Page + 5) > AllPage ? AllPage - 9 : Page - 4;  //中間頁(yè)起始序號(hào)
              EndCount = Page < 5 ? 10 : Page + 5; //中間頁(yè)終止序號(hào)
              if (StartCount < 1) { StartCount = 1; }//為了避免輸出的時(shí)候產(chǎn)生負(fù)數(shù),設(shè)置如果小于1就從序號(hào)1開(kāi)始
              if (AllPage < EndCount) { EndCount = AllPage; }//頁(yè)碼+5的可能性就會(huì)產(chǎn)生最終輸出序號(hào)大于總頁(yè)碼,那么就要將其控制在頁(yè)碼數(shù)之內(nèi)
              PageStr = "共" + AllPage + "頁(yè)      ";
              PageStr += Page > 1 ? "<a href=\"" + FilePath + QueryStr + "Page=1\">首頁(yè)</a>  <a href=\"" + FilePath + QueryStr + "Page=" + Pre + "\">上一頁(yè)</a>" : "首頁(yè) 上一頁(yè)";
              for (int xk = StartCount; xk < EndCount; xk++)
              {
                  PageStr += Page == xk ? "  <font color=\"#ff0000\">" + xk + "</font>" : "  <a href=\"" + FilePath + QueryStr + "Page=" + xk + "\">" + xk + "</a>";
              }
              PageStr += Page != AllPage ? "  <a href=\"" + FilePath + QueryStr + "Page=" + Next + "\">下一頁(yè)</a>  <a href=\"" + FilePath + QueryStr + "Page=" + AllPage + "\">末頁(yè)</a>" : " 下一頁(yè) 末頁(yè)  ";
              return PageStr;
          }
          #endregion
      }

        本站是提供個(gè)人知識(shí)管理的網(wǎng)絡(luò)存儲(chǔ)空間,所有內(nèi)容均由用戶發(fā)布,不代表本站觀點(diǎn)。請(qǐng)注意甄別內(nèi)容中的聯(lián)系方式、誘導(dǎo)購(gòu)買等信息,謹(jǐn)防詐騙。如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請(qǐng)點(diǎn)擊一鍵舉報(bào)。
        轉(zhuǎn)藏 分享 獻(xiàn)花(0

        0條評(píng)論

        發(fā)表

        請(qǐng)遵守用戶 評(píng)論公約

        類似文章 更多