欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

asp.net實現(xiàn)簡單分頁實例

 更新時間:2015年01月08日 11:01:12   投稿:shichen2014  
這篇文章主要介紹了asp.net實現(xiàn)簡單分頁的方法,實例分析了asp.net分頁的基本原理與實現(xiàn)流程,具有一定參考借鑒價值,需要的朋友可以參考下

本文實例講述了asp.net實現(xiàn)簡單分頁的方法。分享給大家供大家參考。

具體實現(xiàn)方法如下:

復(fù)制代碼 代碼如下:
/// <summary>
/// 分頁內(nèi)容
/// </summary>
/// <param name="size">頁面大小</param>
/// <param name="count">頁面數(shù)量</param>
/// <param name="currendIndex">當(dāng)前頁</param>
/// <param name="pattern">url模式:demo.aspx?page={0}</param>
/// <param name="target">窗口模式</param>
/// <returns></returns>
public static string get_pagenation(int size,
                                    int count,
                                    int currendIndex,
                                    string pattern,
                                    string target)
{
    //1>打開窗口目標(biāo)
    target = string.IsNullOrEmpty(target) ? "_top" : target;
    //2>總頁數(shù)
    int pageCount = count / size;
    pageCount = pageCount * size == count ? pageCount : pageCount + 1;
    //3>分頁內(nèi)容
    StringBuilder strHtml = new StringBuilder();
    strHtml.Append("<span class='pagenation'>");
 
    #region 首部處理
    if (currendIndex > 1)
    {
        strHtml.AppendFormat("<a href='1' target='{0}'>[首頁]</a>", target);
        strHtml.AppendFormat("<a href='{0}' target='{1}'>[上一頁]</a>", string.Format(pattern, currendIndex - 1), target);
    }
    else
    {
        strHtml.Append("<span class='disabled'>[首頁]</span>&nbsp;&nbsp;<span class='disabled'>[上一頁]</span>");
    }
    #endregion
 
    #region 中間部分
    int i = 1;
 
    int right = (currendIndex + 4) > pageCount ? pageCount : currendIndex + 4;
    if (currendIndex > 6)
    {
        i = currendIndex - 5;
    }
    else
    {
        right = pageCount >= 10 ? 10 : pageCount;
    }
    for (; i <= right; i++)
    {
        if (i == currendIndex)
        {
            strHtml.AppendFormat("<font class='current'>{0}</font>", i);
            strHtml.AppendLine();
            continue;
        }
        strHtml.AppendFormat("<a href='{0}' target='{1}'>[{2}]</a>", string.Format(pattern, i), target, i);
        strHtml.AppendLine();
    }
    #endregion
 
    #region 尾部處理
    if (currendIndex == pageCount)
    {
        strHtml.Append("<span class='disabled'>[下一頁]</span><span class='disabled'>[末頁]</span>");
        strHtml.AppendFormat("總共({0})頁", pageCount);
    }
    else
    {
        strHtml.AppendFormat("<a href='{0}' target='{1}'>[下一頁]</a>", string.Format(pattern, currendIndex + 1), target);
        strHtml.AppendFormat("<a href='{0}' target='{1}'>[末頁]</a>", string.Format(pattern, pageCount), target);
        strHtml.AppendFormat("&nbsp;&nbsp;<label>總共({0})頁</label>", pageCount);
    }
    #endregion
 
    strHtml.Append("</span>");
 
    return strHtml.ToString();
}

希望本文所述對大家的asp.net程序設(shè)計有所幫助。

相關(guān)文章

  • ASP.NET Core MVC中過濾器工作原理介紹

    ASP.NET Core MVC中過濾器工作原理介紹

    這篇文章介紹了ASP.NET Core MVC中過濾器的工作原理,對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2022-02-02
  • asp.net Repeater分頁實例(PageDataSource的使用)

    asp.net Repeater分頁實例(PageDataSource的使用)

    Asp.net提供了三個功能強大的列表控件:DataGrid、DataList和Repeater控件,但其中只有DataGrid控件提供分頁功能。相對DataGrid,DataList和Repeater控件具有更高的樣式自定義性,所以很多時候我們喜歡使用DataList或Repeater控件來顯示數(shù)據(jù)
    2013-04-04
  • ASP.NET?Core中的Ocelot網(wǎng)關(guān)介紹

    ASP.NET?Core中的Ocelot網(wǎng)關(guān)介紹

    這篇文章介紹了ASP.NET?Core中的Ocelot網(wǎng)關(guān),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2022-04-04
  • asp.net 讀取文本文件并插入數(shù)據(jù)庫的實現(xiàn)代碼

    asp.net 讀取文本文件并插入數(shù)據(jù)庫的實現(xiàn)代碼

    最近我司和招行有合作,招行給財務(wù)的是一個txt格式的賬務(wù)文本文件,文本文件包含很多內(nèi)容,對賬只需要用到其中一部分內(nèi)容。
    2010-04-04
  • Asp.net中使用Sqlite數(shù)據(jù)庫的方法

    Asp.net中使用Sqlite數(shù)據(jù)庫的方法

    Sqlite是最近比較流行的數(shù)據(jù)庫了,擁有比Access高效快速,易操作易實施。完全不需要在客戶端進行任何的配置,只需要在站點中引用入DLL文件即可使用了。
    2009-11-11
  • asp.net 文件下載的通用方法

    asp.net 文件下載的通用方法

    一則雕蟲小技,記下備忘,以使同學(xué)們少走彎路。
    2009-06-06
  • C# 小數(shù)位數(shù)保留的方法集錦

    C# 小數(shù)位數(shù)保留的方法集錦

    c#下關(guān)于小數(shù)位數(shù)的一些實現(xiàn)方法集合,方便對c#小數(shù)位數(shù)控制的朋友。
    2008-12-12
  • asp.net DataTable導(dǎo)出Excel自定義列名的方法

    asp.net DataTable導(dǎo)出Excel自定義列名的方法

    本文分享了asp.net DataTable導(dǎo)出Excel 自定義列名的具體實現(xiàn)方法,步驟清晰,代碼詳細,需要的朋友可以參考借鑒,下面就跟小編一起來看看吧
    2016-12-12
  • .NET操作Excel實例分享

    .NET操作Excel實例分享

    這篇文章主要介紹了.NET操作Excel實例,有需要的朋友可以參考一下
    2014-01-01
  • .NET?Core?使用委托實現(xiàn)動態(tài)流程組裝的思路詳解

    .NET?Core?使用委托實現(xiàn)動態(tài)流程組裝的思路詳解

    模擬管道模型中間件(Middleware)部分,運用委托,進行動態(tài)流程組裝,本次代碼實現(xiàn)就直接我之前寫的動態(tài)代理實現(xiàn)AOP的基礎(chǔ)上改的,就不另起爐灶了,主要思路就是運用委托,具體實現(xiàn)過程跟隨小編一起看看吧
    2022-01-01

最新評論