Copy Code code 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 PDS = new PagedDataSource ();
Pds. DataSource = Li;
Pds. AllowPaging = true;
Pds. PageSize = 2;
int curpage;
if (request.querystring["page"]!= null)
{
Curpage = Convert.ToInt32 (request.querystring["page");
}
Else
{
Curpage = 1;
}
Pds. 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> record </a>";
This. Label4.text + = "<a> per page display <font color=red><b>" + PDS. PageSize + "</b></font> bar </a>";
This. Label4.text + = "<a> altogether <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> home </a>";
This. Label4.text = "<a> prev </a>";
}
Else
{
This. Label4.text + = "<a href= ' wjproduct-1-" + menu_id + ". html ' > Home </a>";
This. Label4.text + = "<a href= ' wjproduct-" + (curPage-1). ToString () + "-" + menu_id + ". html ' > Prev </a> ';
This. Label4.text + = "<a href= ' repeaterfenye.aspx ' > Home </a>";
This. Label4.text + = "<a href= ' repeaterfenye.aspx?page=" + (curPage-1). ToString () + "' > Prev </a>";
}
if (Curpage = PDS. PageCount)
{
This. Label4.text + = "<a> next page </a>";
This. Label4.text + = "<a> last </a>";
}
Else
{
This. Label4.text + = "<a href= ' repeaterfenye.aspx?page=" + (Curpage + 1). ToString () + "' > next page </a>";
This. Label4.text + = "<a href= ' repeaterfenye.aspx?page=" + PDS. Pagecount.tostring () + "' > Last </a>";
This. Label4.text + = "<a href= ' wjproduct-" + (Curpage + 1). ToString () + "-" + menu_id + ". html ' > Next </a>";
This. Label4.text + = "<a href= ' wjproduct-" + PDS. Pagecount.tostring () + "-" + menu_id + ". html ' > End </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>" + i + "page </option>";
Htmlselectstring + = "<option value= ' repeaterfenye.aspx?page=" + i.tostring () + "' selected> ' + i +" page </option> ;";
}
Else
{
Htmlselectstring + + "<option value=wjproduct-" + i + "-" + menu_id + ".html>" + i + "page </option>";
Htmlselectstring + + "<option value= ' repeaterfenye.aspx?page=" + i.tostring () + "' >" + i + "page </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 that Li returns is all of the records in the table after the SQL query ...