AspNetPager comparison of true and false pages

Source: Internet
Author: User

AspNetPager comparison of true and false pages

It has been a while since learning BS. BS is designed for Web pages, including the data retrieved from the database and displayed on the page. Previously, in CS, table controls such as GridView were used for display. Because of the small data size and the scroll wheel on the right side. Therefore, we have never considered paging data. This is a big mistake. It's not too late to respond now. Next, let's take a look at the page.

Disadvantages of not paging:

Query big data.

1. the loading time of the form is too slow because the data volume is too large.

2. The displayed data volume is too large, and the user looks uncomfortable.

Two paging methods:

False pagination:

When performing a query, all the data is queried, and you do not need to query the data when you jump to the page.

Real paging:

During the query operation, only the content on the current page displayed in the query is displayed. You also need to query the database to retrieve the corresponding data on the page.

Comparison of large data volumes:

In the case of small data, because the current computer processing speed is fast enough, there is no difference between the use of real paging and false paging user experience.

For more information about how to add the AspNetPager control, refer to the following article:

Http://blog.csdn.net/u010066934/article/details/38374111

True/false paging instance result graph:

Use the built-in GridView table to display data. Use the AspNetPager Control for paging.

For details about how to use AspNetPager, refer ---. I will not go into details.

Html main interface:

 
 


First, set a paging control in the header, and then copy the control above to the bottom to synchronize the control.

To compare the true and false pagination, first check the implementation of the false pagination:

Using System; using System. collections. generic; using System. linq; using System. web; using System. web. UI; using System. web. UI. webControls; using System. data; using System. data. sqlClient; namespace news {public partial class JiaFenYe: System. web. UI. page {DataView dv = new DataView (DB. getSource (); protected void Page_Load (object sender, EventArgs e) {// anpTop. recordCount = DB. count (); // Save the total number of data records to the page control. // GridView1.DataSource = DB. getSource (1, 5); // The default value is 5 Records. // GridView1.DataBind (); anpTop. recordCount = DB. count (); // Save the total number of data records to the page control dv. rowFilter = "id <= 5"; // by default, the first page displays 5 Records: GridView1.DataSource = dv; GridView1.DataBind (); // bind a view} protected void anp_PageChanged (object sender, eventArgs e) {// Response. write ("start page:" + anpTop. startRecordIndex +"
End page: "+ anpTop. endRecordIndex); int startIndex = anpTop. startRecordIndex; // the actual record number int endIndex = anpTop. endRecordIndex; // end record No. // DataView dv = new DataView (DB. getSource (); dv. rowFilter = "id> =" + startIndex + "and id <=" + endIndex; // query the records in the specified range, GridView1.DataSource = dv; GridView1.DataBind (); // bind view }}}


In comparison, the implementation of real paging:

Using System; using System. collections. generic; using System. linq; using System. web; using System. web. UI; using System. web. UI. webControls; namespace news {public partial class WebForm1: System. web. UI. page {protected void anp_PageChanged (object sender, EventArgs e) {// Response. write ("start page:" + anpTop. startRecordIndex +"
End page: "+ anpTop. endRecordIndex); int startIndex = anpTop. startRecordIndex; // The number of starting records of the data. int endIndex = anpTop. endRecordIndex; // The number of data cutoff records. GridView1.DataSource = DB. getSource (startIndex, endIndex); // display GridView1.DataBind ();} protected void Page_Load (object sender, EventArgs e) {anpTop. recordCount = DB. count (); // Save the total number of data records to the page control. GridView1.DataSource = DB. getSource (); // 5 records are selected by default. GridView1.DataBind ();}}}

By comparing the above experimental results, because the test data is too small, the effect is not obvious. However, through the code implementation process, we can see that, on the premise of big data, false paging loading is a big problem. Of course, the two paging methods have their own characteristics and can be selected based on actual needs.

If you need to view the source code, download it by yourself:

Http://download.csdn.net/detail/zc474235918/7734743


Related Article

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.