Aspnetpager Usage Introduction

Source: Internet
Author: User

The Aspnetpager pagination control solves many of the problems in paging, and it is easy to use this control for paging, which simplifies the tedious paging process.

The effect is as follows:

Here is the detailed code for how I use the Aspnetpager control for paging:

1. First download the latest AspNetPager.dll to and add the reference directly to the VS2005.

2. Register the control on the page, introduce the control, and, of course, need to use a data carrier in the page, I'm using the Repeater control.

To register the paging control code:

<%@ Register assembly="aspnetpager" namespace="wuqi.webdiyer" tagprefix="webdiyer" %>

3. Pagination Control page code:

<Webdiyer:aspnetpagerID= "AspNetPager1"runat= "Server"Alwaysshow= "True"onpagechanged= "Aspnetpager1_pagechanged"PageSize= "5"Shownavigationtooltip= "True"Firstpagetext= "First page"Lastpagetext= "Last Page"NextPageText= "Next Page"Prevpagetext= "Previous page"Submitbuttontext= "Go"Textafterpageindexbox= "page"Textbeforepageindexbox= "Go to"Font-bold= "True"Font-italic= "False"font-size= "Small"Showpageindexbox= "Always">                                    </Webdiyer:aspnetpager>

4. Background code:

Using LINQ technology:

usingSystem;usingSystem.Collections;usingSystem.Configuration;usingSystem.Data;usingSystem.Linq;usingsystem.web;usingSystem.Web.Security;usingSystem.Web.UI;usingSystem.Web.UI.WebControls;usingSystem.Web.UI.WebControls.WebParts;usingSystem.Web.UI.HtmlControls;usingSystem.Xml.Linq;{ Public Partial classDefault:System.Web.UI.Page {protected voidPage_Load (Objectsender, EventArgs e) {            if(!IsPostBack)            {initnews (); }        }        Private voidinitnews () {entitydbdatacontext DC=NewEntitydbdatacontext (); intpage = This.            Aspnetpager1.currentpageindex; intSize = This.            Aspnetpager1.pagesize; varNewslist = Dc.t_news. OrderByDescending (p            ToList (); varNews = Newslist.skip (Size * (Page-1)). Take (size).                       ToList (); if(News! =NULL&& News. Count >0) {Aspnetpager1.recordcount=Newslist.count; Newsdl.datasource=News;            Newsdl.databind (); }            Else{Aspnetpager1.recordcount=0; Newsdl.datasource=NULL;            Newsdl.databind (); }        }        protected voidAspnetpager1_pagechanged (Objectsender, EventArgs e)        {initnews (); }    }}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

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.