免费视频淫片aa毛片_日韩高清在线亚洲专区vr_日韩大片免费观看视频播放_亚洲欧美国产精品完整版

打開(kāi)APP
userphoto
未登錄

開(kāi)通VIP,暢享免費(fèi)電子書(shū)等14項(xiàng)超值服

開(kāi)通VIP
GridView分頁(yè)之通用類(lèi)
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.Generic;
/// <summary>
/// GridViewPager 的摘要說(shuō)明
/// </summary>
public class GridViewPager<T>
{
    public GridViewPager()
    {
        //
        // TODO: 在此處添加構(gòu)造函數(shù)邏輯
        //
    }
    public static string GetPageNum(IList<T> list, GridView GridViewName, 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;
        GridViewName.DataSource = ObjPds;
        GridViewName.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;
    }
}
本站僅提供存儲(chǔ)服務(wù),所有內(nèi)容均由用戶(hù)發(fā)布,如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請(qǐng)點(diǎn)擊舉報(bào)
打開(kāi)APP,閱讀全文并永久保存 查看更多類(lèi)似文章
猜你喜歡
類(lèi)似文章
我的分頁(yè)方法
excel批量導(dǎo)入數(shù)據(jù)
App開(kāi)放接口api安全性
Delphi XE7 用indy開(kāi)發(fā)微信公眾平臺(tái)(3)
C#中方法的參數(shù)
.net程序員的盲點(diǎn)(一):ref,out ,params的區(qū)別
更多類(lèi)似文章 >>
生活服務(wù)
分享 收藏 導(dǎo)長(zhǎng)圖 關(guān)注 下載文章
綁定賬號(hào)成功
后續(xù)可登錄賬號(hào)暢享VIP特權(quán)!
如果VIP功能使用有故障,
可點(diǎn)擊這里聯(lián)系客服!

聯(lián)系客服