Non-database data source paging implementation

Source: Internet
Author: User
 
Test URL:
202.127.144.107/overred/nodatapage.htm
Download address:
Chinaeduonline.net/rar/nodatapage.rar
Detailed descriptions are provided.
Main code:
Bind the data source of ArrayList (or array) to repeater and perform paging
++ Demo ++
Aspx
__________________________________________
<Body>
<Form id = "Form1" method = "post" runat = "server">
<FONT face = "">
<P> <asp: repeater id = "rtest" runat = "server" DataMember = "1">
<ItemTemplate>
<Font color = "# ff3366">
<% # Container. DataItem %>
<Br>
</Font>
</ItemTemplate>
</Asp: repeater> </P>
<P> current page: & nbsp;
<Asp: Label id = "dq" runat = "server"> 1 </asp: Label> </P>
<P>
<Asp: Label id = "link" runat = "server"> Label </asp: Label> </P>
</FONT>
</Form>
</Body>
____________________________________________________
. Cs
____________________________________________________________
Public class t1: System. Web. UI. Page
{
Protected System. Web. UI. WebControls. Label dq;
Protected System. Web. UI. WebControls. Label link;
Protected System. Web. UI. WebControls. Label d;
Protected System. Web. UI. WebControls. Repeater rtestt;
Protected System. Web. UI. WebControls. Repeater rtest;
Private int pagesize; // number of records displayed on each page
Public void Page_Load (object sender, System. EventArgs e)
{
// Place user code here to initialize the page
If (! Page. IsPostBack)
Pagesize = 40; // number of records displayed per page
This. rtest. DataSource = Datasource (); // bind the data source directly.
This. rtest. DataBind ();
}
// Set ArrayList for ArrayList Datasource ()
Public ArrayList Data ()
{
// ++ Construct a data source for repeater, the length variable is j ++ ++
ArrayList s = new ArrayList ();
For (int j = 1; j <100; j ++)
S. Add ("aa" + j. ToString ());
Return s;
// ++ ++ ++

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.