【轉】AspNetPager分頁控制項用法

來源:互聯網
上載者:User

標籤:分頁控制項   style   http   color   io   os   使用   ar   資料   

AspNetPager分頁控制項解決了分頁中的很多問題,直接採用該控制項進行分頁處理,會將繁瑣的分頁工作變得簡單化,下面是我如何使用AspNetPager控制項進行分頁處理的詳細代碼:
1.首先到www.webdiyer.com下載最新的AspNetPager.dll,直接在vs2005中添加引用即可。
2.在頁面上註冊控制項,引入該控制項,當然,需要在頁面中使用一個資料載體,我這裡使用的是repeater控制項。

<%@ Register Assembly="AspNetPager" Namespace="Wuqi.Webdiyer" TagPrefix="webdiyer" %>

 

<webdiyer:aspnetpager id="AspNetPager1" runat="server" CurrentPageButtonPosition="Center"
    Width="100%"  AlwaysShowFirstLastPageNumber="true" PagingButtonSpacing="10px" FirstPageText="首頁"
        LastPageText="尾頁" NextPageText="下一頁" PrevPageText="上一頁" CustomInfoTextAlign="Center"  ShowNavigationToolTip="True" SubmitButtonText="跳" HorizontalAlign="Right" ButtonImageNameExtension="n" CpiButtonImageNameExtension="r"></webdiyer:aspnetpager>

3.cs代碼

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace Pager
{
    public partial class Demo_1 : System.Web.UI.Page
    {
        DAL.Books booksdal = new DAL.Books();
        int pagesize = 10;
        protected void Page_Load(object sender, EventArgs e)
        {
           
            if (this.IsPostBack)
            {
            }
            AspNetPager2.RecordCount = 1076;
            Band();
        }

        void Band()
        {
            this.Repeater1.DataSource = booksdal.GetTable(pagesize, AspNetPager2.StartRecordIndex,AspNetPager2.EndRecordIndex);
            this.Repeater1.DataBind();
     //public DataTable GetTable(int pagesize,int staindex,int endindex)
        //{
            
        //    string sql = " select top (@pagesize) * from (SELECT ROW_NUMBER() OVER (ORDER BY id) AS RowNumber,* FROM Books ) as A where A.RowNumber between @staindex and @endindex";
        //    SqlParameter[] pars = new SqlParameter[]
        //    {
        //        new SqlParameter("@pagesize",pagesize),
        //        new SqlParameter("@staindex",staindex),
        //        new SqlParameter("@endindex",endindex)
        //    };
           
        //    return DAL.SQL_Help.GetTable(sql, pars);
           
        //}
        }

        protected void AspNetPager1_PageChanged(object sender, EventArgs e)
        {
            Band();
        }
       
    }
}

【轉】AspNetPager分頁控制項用法

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.