asp.net--true and false pagination

Source: Internet
Author: User

The so-called paging, is to display all the content to be divided into more than n pages to display. Why do you use pagination instead of displaying it all directly? This is like a book, we can write the contents of all the books with a piece of paper, but we don't actually do it. We divide the page into one page, in fact, to a large extent in the user's consideration, great user convenience.

There are two kinds of pagination, one is true paging, and the other is false paging.

False paging " false " is that I have taken all the data out, but in the display of the time given some control to reach the effect of paging.

True paging " true " is that all the data is not taken out at once, but really the real user to see which page to go to the database to remove the required content.

false Paging:

In ASP. NET, we often use gridview,repeater to bind the data source to show the data that is found in the database. Let's take the GridView example to see how false paging is implemented.

First, add the GridView to the page. and set the number of bars that are allowed to be paged and paginated, that is, allowpaging=true,pagesize=6. (i.e. 6 records per page)


When you run the interface, you can display the paging state. However, when you click the button on page 2nd, the Pageindexchanging event is triggered when a pager button is clicked, but before the GridView control handles the paging operation.

public partial class Test:System.Web.UI.Page    {        protected void Page_Load (object sender, EventArgs e)        {            When you first enter the page, the bound data is displayed            if (! Page.IsPostBack)            {                Gridview1.datasource = new Newsmanager (). SelectAll (); The layering is used here and can be directly understood as a table in the binding database.                Gridview1.databind ();            }        }        Trigger paging event        protected void Gridview1_pageindexchanging (object sender, Gridviewpageeventargs e)        {            Gridview1.pageindex = E.newpageindex;            Gridview1.datasource = new Newsmanager (). SelectAll ();            Gridview1.databind ();        }    }
in this way, false paging can be achieved.

true Paging:

Here, a paging control aspnetpager is used.

First, add the control.

Right-click on the Toolbox tab

After you click Browse, locate AspNetPager.dll.


The control is then present in the Toolbox.


Drag it to the design interface, such as:


      pagination control is added, similarly, sets the number of display bars and the maximum number of records per page. At this point, the pagechanged event is executed when the number of pages is changed. startrecordindex,  endrecordindex are the number of start and end lines, respectively. Using these two parameters is easy to implement from the database one page < Span style= "Font-family:microsoft Yahei; font-size:18px "> a page to take out the data, here will not repeat it.


Compare the two paging methods:

True Paging and the background of the number of interactions, but the face of huge data can still maintain high efficiency, user experience is good. False pagination is the opposite.


Report:

Paging statements in SQL

The number of records displayed per page of select TOP (PageSize) * from topic where ID not in   (current page-1) x number of records displayed per page ID from topic Order by ID de SC)   ORDER BY id DESC

aspnetpager pagination Control

Http://www.jb51.net/codes/40809.html


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: info-contact@alibabacloud.com 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.