Asp.net list data display + Paging

Source: Internet
Author: User

A csdn user put it in the download

 

/////////////////

/// <Summary> <br/> // paging function <br/> /// </Summary> <br/> /// <Param name = "dtrecord"> data source </param> <br/> private void splitpage (datatable dtrecord) <br/>{< br/> string htmlpage = ""; <br/> int pagesize = 15; // number of records displayed on each page <br/> int liststep = 10; // display the maximum number of pages <br/> int pages = 1; // the current page. The first page is displayed by default. <br/> int pagecount = 0; // define the total number of pages <br/> int recordcount = 0; // define the total number of records <br/> int listbegin = 0; // display the page information starting from the page number <br/> int listend = 0; // Page information displayed on the page </P> <p> If (dtrecord = NULL | dtrecord. rows. count = 0) <br/>{< br/> return; <br/>}< br/> recordcount = dtrecord. rows. count; </P> <p> // determine the number of pages to be displayed for the data record <br/> If (recordcount> 0) <br/>{< br/> pagecount = recordcount/pagesize; <br/>}< br/> If (recordcount % pagesize> 0) <br/>{< br/> pagecount ++; <br/>}</P> <p> // obtain the current page number, determine <br/> If (request ["pages"]! = NULL) <br/>{< br/> pages = convert. toint32 (request ["pages"]); <br/>}< br/> If (pages <1) <br/>{< br/> pages = 1; <br/>}< br/> If (pages> pagecount) <br/>{< br/> pages = pagecount; <br/>}</P> <p> listbegin = pages-liststep/2; // display page information starting from the page number <br/> If (listbegin <1) <br/>{< br/> listbegin = 1; <br/>}</P> <p> listend = listbegin + liststep-1; // page information displayed on the page <br/> If (listend> pagecount) <br/>{< br/> listend = pagecount; <br/> listbegin = listend-liststep + 1; </P> <p> If (listbegin <1) <br/>{< br/> listbegin = 1; <br/>}</P> <p> // confirm the start and end records on the current page. <br/> int recordbegin = pagesize * (pages- 1 ); <br/> int recordend = recordbegin + pagesize-1; <br/> If (recordend> recordcount-1) <br/> {<br/> recordend = recordcount-1; <br/>}</P> <p> // display data records <br/> htmlpage = displaydatarecord (dtrecord, recordbegin, recordend); <br/> response. write (htmlpage); <br/> htmlpage = ""; </P> <p> // display the page list <br/> htmlpage + = getpagelist (pages, pagecount, listbegin, listend); <br/> response. write (htmlpage); <br/> htmlpage = ""; <br/>}< br/>

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.