国产一级a片免费看高清,亚洲熟女中文字幕在线视频,黄三级高清在线播放,免费黄色视频在线看

打開APP
userphoto
未登錄

開通VIP,暢享免費電子書等14項超值服

開通VIP
我的分頁方法

public enum DataShowControl { DataList, GridView, Repeater };

public enum FenYeStyle { Stander, ListStyle, Google };

public class CommFenYe

{

    public CommFenYe()

    {}

    /// <summary>

    /// 分頁方法

    /// </summary>

    /// <param name="ds">數(shù)據(jù)源</param>

    /// <param name="pageSize">每頁顯示數(shù)</param>

    /// <param name="gv">數(shù)據(jù)控件</param>

    /// <param name="control">數(shù)據(jù)控件樣式</param>

    /// <param name="fystyle">分頁樣式</param>

    /// <returns>返回分頁樣式字符串</returns>

    public string fenye(DataSet ds, int pageSize, Object gv, DataShowControl control, FenYeStyle fystyle)

    {

        PagedDataSource pagesource = new PagedDataSource(); //實例化分頁數(shù)據(jù)源

        pagesource.AllowPaging = true;//分頁屬性

        pagesource.PageSize = pageSize;//每頁顯示數(shù)

        pagesource.DataSource = ds.Tables[0].DefaultView;//提供數(shù)據(jù)源

        int currentPage = 1;

        if (!string.IsNullOrEmpty(HttpContext.Current.Request["page"]))

        {

            currentPage = Convert.ToInt16(HttpContext.Current.Request["page"]);

            if (currentPage < 1) currentPage = 1;

            if (currentPage > pagesource.PageCount) currentPage = pagesource.PageCount;

        }

        pagesource.CurrentPageIndex = currentPage - 1;

      

        if (control == DataShowControl.DataList) //給不同的數(shù)據(jù)控件綁定數(shù)據(jù)

        {

            ((DataList)gv).DataSource = pagesource;

            ((DataList)gv).DataBind();

        }

        if (control == DataShowControl.GridView)

        {

            ((GridView)gv).DataSource = pagesource;

            ((GridView)gv).DataBind();

        }

        if (control == DataShowControl.Repeater)

        {

            ((Repeater)gv).DataSource = pagesource;

            ((Repeater)gv).DataBind();

        }

        string str = "", path = HttpContext.Current.Request.Path;//用不同的方法實現(xiàn)分頁

    

        if (fystyle == FenYeStyle.Stander)//標(biāo)準(zhǔn)分頁

        {

            str = "<a href=" + path + "?page=1>首頁</a>|" +

                          "<a href=" + path + "?page=" + (currentPage - 1) + ">上一頁</a>|" +

                          "<a href=" + path + "?page=" + (currentPage + 1) + ">下一頁</a>|" +

                          "<a href=" + path + "?page=" + pagesource.PageCount + ">末頁</a>";

        }

        if (fystyle == FenYeStyle.ListStyle)//列表分頁

        {

            for (int i = 1; i <= pagesource.PageCount; i++)

            {

                if (i == currentPage)

                {

                    str += "[<font color='red' size='4'><b>" + i + "</b></font>]  ";

                }

                else

                {

                    str += "[<a href='" + path + "?page=" + i + "'>" + i + "</a>]  ";

                }

            }

        }

        int startcount = 0, endcount = 0;

        int page = currentPage;

        int allpage = pagesource.PageCount;

        string query_string = path;

        int next = currentPage + 1, pre = currentPage - 1;

        if (fystyle == FenYeStyle.Google)//狗狗分頁

        {

            startcount = (page + 5) > allpage ? allpage - 9 : page - 4;//中間頁起始序號

           

            endcount = page < 5 ? 10 : page + 5;//中間頁終止序號

//為了避免輸出的時候產(chǎn)生負(fù)數(shù),設(shè)置如果小于1就從序號1開始

            if (startcount < 1) { startcount = 1; }

//頁碼+5的可能性就會產(chǎn)生最終輸出序號大于總頁碼,那么就要將其控制在頁碼數(shù)之內(nèi)

            if (allpage < endcount) { endcount = allpage; }

            str = "<font color='red'>" + allpage + "</font>/當(dāng)前第<font color='red'>" + page + "</font>";

            str += page > 1 ? "<a href=\"" + query_string + "?page=1\">首頁</a>   <a href=\"" + query_string + "?page=" + pre + "\">上一頁</a>" : "首頁 上一頁";

//中間頁處理,這個增加時間復(fù)雜度,減小空間復(fù)雜度

            for (int i = startcount; i <= endcount; i++)

            {

                str += page == i ? "   <font color=\"#ff0000\">" + i + "</font>" : "   <a href=\"" + query_string + "?page=" + i + "\">" + i + "</a>";

            }

            str += page != allpage ? " <a href=\"" + query_string + "?page=" + next + "\">下一頁</a><a href=\"" + query_string + "?page=" + allpage + "\">末頁</a>" : " 下一頁 末頁";

        }

        return str;//返回分頁樣式字符串

    }

}

 

本站僅提供存儲服務(wù),所有內(nèi)容均由用戶發(fā)布,如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請點擊舉報。
打開APP,閱讀全文并永久保存 查看更多類似文章
猜你喜歡
類似文章
oracle數(shù)據(jù)庫:jdbc通用sql分頁封裝
ASP.NET MVC 使用FCKEditor的分頁符進行文章分頁HMCWEB.net 專...
s2sh 底層封裝(增,刪,改,查,分頁)
JDBC基礎(chǔ)
自定義標(biāo)簽--hibernate分頁技術(shù)
ASP.NET含HTML標(biāo)記的內(nèi)容分頁_qian81's blog
更多類似文章 >>
生活服務(wù)
分享 收藏 導(dǎo)長圖 關(guān)注 下載文章
綁定賬號成功
后續(xù)可登錄賬號暢享VIP特權(quán)!
如果VIP功能使用有故障,
可點擊這里聯(lián)系客服!

聯(lián)系客服