Paging of the Repeater control

Source: Internet
Author: User
Paging of the Repeater control
Protected system. Web. UI. webcontrols. Repeater rptframework
Private void page_load (Object sender, system. eventargs E)
{
// Create a dataset
(This part is omitted)
Rptframework. datasource = mydataset;
Rptframework. databind ();
Session ["page"] = 1;
// Hide all repeater entries
Int I = 0;
For (I = 0; I <rptframework. Items. Count; I ++)
{
Rptframework. items [I]. Visible = false;
}
// Page size of the Repeater control
Int intpagesize = 10;
// Index of the current page of The rptframework control (starting from 1)
Int intcurrentpageindex = 0;
If (request. querystring ["page"] = NULL | convert. toint32 (request. querystring ["page"]) = 0)
{
Session ["page"] = 1;
}
Else
{
Session ["page"] = convert. toint32 (request. querystring ["page"]);
}
Intcurrentpageindex = convert. toint32 (session ["page"]);
// Button blocking on the previous page
If (convert. toint32 (session ["page"]) = 1)
{
Btnpre. Enabled = false;
}
// Current cursor index of the rptframework control (starting from 1)
Int intcurrentitemindex = 1;
Intcurrentitemindex = intpagesize * (intcurrentpageindex-1) + 1;
// Button blocking on the next page
If (rptframework. Items. Count-intcurrentitemindex) <intpagesize)
{
Btnnext. Enabled = false;
}
// Set the default view for form Loading
If (rptframework. Items. Count> intpagesize)
{
For (I = intcurrentitemindex; I <getmin (rptframework. Items. Count, intcurrentitemindex + intpagesize); I ++)
{
Rptframework. items [I-1]. Visible = true;
}
}
// Take the smaller values of the two values, but do not change the original value size
Private int getmin (int A, int B)
{
Int C;
If (A> B)
{
C = B;
}
Else
{
C =;
}
Return C;
}
// CLICK THE PREVIOUS PAGE
Private void btnpre_click (Object sender, system. eventargs E)
{
Int intprepageindex = 2;
If (convert. toint32 (session ["page"])! = 1)
{
Intprepageindex = convert. toint32 (session ["page"])-1;
}
Else
{
Intprepageindex = 1;
}
Response. Redirect ("jggk. aspx? Page = "+ intprepageindex. tostring ());
}
// Click the next page
Private void btnnext_click (Object sender, system. eventargs E)
{
Int intnextpageindex = convert. toint32 (session ["page"]) + 1;
Response. Redirect ("jggk. aspx? Page = "+ intnextpageindex. tostring ());
}


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.