web分頁控制項AspNetPager的使用

來源:互聯網
上載者:User

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

首先要先引用AspNetPager.dll檔案

然後在<html>上面添加下面代碼:

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

然後在repeater控制項下添加AspNetPager控制項:

<webdiyer:aspnetpager id="AspNetPager1"
           runat="server"
           PageSize="100"
           AlwaysShow="True"
           OnPageChanged="AspNetPager1_PageChanged"
           ShowCustomInfoSection="left"
           CustomInfoSectionWidth=""
           ShowPageIndexBox="Always"
           PageIndexBoxType="DropDownList"
           CustomInfoHTML="共<font color=‘red‘><b>%RecordCount%</b></font>條記錄" FirstPageText="首頁" LastPageText="末頁" NextPageText="下一頁" PrevPageText="上一頁">
</webdiyer:aspnetpager>

接著在後台代碼中分頁:

AspNetPager1.CurrentPageIndex = 1;//設定或擷取當前頁
 PagedDataSource pds = new PagedDataSource();//建立資料集
 pds.CurrentPageIndex = AspNetPager1.CurrentPageIndex - 1;設定索引(索引從0開始)
 pds.DataSource = new List<SalesCarModel>();//清空資料來源
 pds.AllowPaging = true;//是否啟用分頁
 pds.PageSize = AspNetPager1.PageSize;//擷取或設定每頁的項數
 ucSalesCar.DataBindSource(pds) ;//綁定到資料控制項
 BindDatasource();//一個方法:主要是查詢的條件和查詢的結果和對分頁控制項的屬性設定

private void AspNetPager1_PageChanged(object sender, EventArgs e)

{

  BindDatasource();更新頁數

}

這樣就完成了

---做筆記

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.