CopyCode The Code is as follows: using system;
Using system. Collections. Generic;
Using system. LINQ;
Using system. Web;
Using system. Web. UI;
Using system. Web. UI. webcontrols;
Using BLL;
Using model;
Using system. Data. sqlclient;
Using system. Data;
Public partial class test_repeaterfenye: system. Web. UI. Page
{
Private readonly static categorybll cb = new categorybll ();
Private readonly static category_info CGI = new category_info ();
Int menu_id = 0;
Protected void page_load (Object sender, eventargs E)
{
If (! Ispostback)
{
Binddata ();
}
}
Private void binddata ()
{
Ilist <category_info> li = CB. getallcategory ();
If (Li. Count> 0)
{
Pageddatasource PPS = new pageddatasource ();
PPS. datasource = Li;
PPS. allowpaging = true;
PPS. pagesize = 2;
Int curpage;
If (request. querystring ["page"]! = NULL)
{
Curpage = convert. toint32 (request. querystring ["page"]);
}
Else
{
Curpage = 1;
}
PPS. currentpageindex = curpage-1;
This. repeater1.datasource = PDS;
This. repeater1.databind ();
This. label4.text = "";
This. label4.text + = "<A> total <font color = Red> <B>" + Li. count. tostring () + "</B> </font> records </a> ";
This. label4.text + = "<A> each page is displayed <font color = Red> <B>" + PDS. pagesize + "</B> </font> </a> ";
This. label4.text + = "<A> total <font color = Red> <B>" + PDS. pagecount. tostring () + "</B> </font> page </a> ";
This. label4.text + = "<A> current <font color = Red> <B>" + curpage. tostring () + "</B> </font> page </a> ";
If (curpage = 1)
{
This. label4.text + = "<A> homepage </a> ";
This. label4.text + = "<A> previous page </a> ";
}
Else
{
// This. label4.text + = "<a href = 'wjproduct-1-" + menu_id + ". html '> homepage </a> ";
// This. label4.text + = "<a href = 'wjproduct-" + (curpage-1 ). tostring () + "-" + menu_id + ". HTML '> previous page </a> ";
This. label4.text + = "<a href = 'repeaterfenye. aspx '> homepage </a> ";
This. label4.text + = "<a href = 'repeaterfenye. aspx? Page = "+ (curpage-1). tostring () +" '> previous page </a> ";
}
If (curpage = PPS. pagecount)
{
This. label4.text + = "<A> next page </a> ";
This. label4.text + = "<A> last page </a> ";
}
Else
{
This. label4.text + = "<a href = 'repeaterfenye. aspx? Page = "+ (curpage + 1). tostring () +" '> next page </a> ";
This. label4.text + = "<a href = 'repeaterfenye. aspx? Page = "+ PPS. pagecount. tostring () +" '> last page </a> ";
// This. label4.text + = "<a href = 'wjproduct-" + (curpage + 1 ). tostring () + "-" + menu_id + ". HTML '> next page </a> ";
// This. label4.text + = "<a href = 'wjproduct-" + PDS. pagecount. tostring () + "-" + menu_id + ". HTML '> end page </a> ";
}
String htmlselectstring = "<select onchange = \" javascript: window. Location = This. Value \ "> ";
For (INT I = 1; I <= PDs. pagecount; I ++)
{
If (I = curpage)
{
// Htmlselectstring + = "<option value = wjproduct-" + I + "-" + menu_id + ". html selected> page" + I + "</option> ";
Htmlselectstring + = "<option value = 'repeaterfenye. aspx? Page = "+ I. tostring () +" 'selected> page "+ I +" </option> ";
}
Else
{
// Htmlselectstring + = "<option value = wjproduct-" + I + "-" + menu_id + ". html> page" + I + "</option> ";
Htmlselectstring + = "<option value = 'repeaterfenye. aspx? Page = "+ I. tostring () +" '> page "+ I +" </option> ";
}
}
Htmlselectstring + = "</SELECT> ";
This. label4.text + = "<A>" + htmlselectstring + "</a> ";
}
Else
{
Label4.text = "no data! ";
}
}
}
Note: // The comment part is the effect of URL rewrite... The value returned by Li is all records in the table after SQL query...