色尼玛亚洲综合影院,亚洲3atv精品一区二区三区,麻豆freexxxx性91精品,欧美在线91

asp.net repeater手寫分頁實例代碼

復制代碼 代碼如下:
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>共有<font color=red><b>" + li.Count.ToString() + "</b></font>條記錄</a> ";
this.Label4.Text += "<a>每頁顯示<font color=red><b>" + pds.PageSize + "</b></font>條</a> ";
this.Label4.Text += "<a>共<font color=red><b>" + pds.PageCount.ToString() + "</b></font>頁</a> ";
this.Label4.Text += "<a>當前第<font color=red><b>" + curPage.ToString() + "</b></font>頁</a>  ";
if (curPage == 1)
{
this.Label4.Text += "<a>首頁</a> ";
this.Label4.Text += "<a></a> ";
}
else
{
//this.Label4.Text += "<a href='wjProduct-1-" + Menu_ID + ".html'>首頁</a> ";
//this.Label4.Text += "<a href='wjProduct-" + (curPage - 1).ToString() + "-" + Menu_ID + ".html'></a>  ";
this.Label4.Text += "<a href='RepeaterFENYE.ASPx'>首頁</a> ";
this.Label4.Text += "<a href='RepeaterFENYE.ASPx?page="+(curPage - 1).ToString()+"'></a>  ";
}
if (curPage == pds.PageCount)
{
this.Label4.Text += "<a></a> ";
this.Label4.Text += "<a>尾頁</a> ";
}
else
{
this.Label4.Text += "<a href='RepeaterFENYE.ASPx?page=" + (curPage + 1).ToString() + "'></a>  ";
this.Label4.Text += "<a href='RepeaterFENYE.ASPx?page=" + pds.PageCount.ToString() + "'>尾頁</a>  ";
//this.Label4.Text += "<a href='wjProduct-" + (curPage + 1).ToString() + "-" + Menu_ID + ".html'></a> ";
//this.Label4.Text += "<a href='wjProduct-" + pds.PageCount.ToString() + "-" + Menu_ID + ".html'>尾頁</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 + "頁</option>";
HtmlSelectString += "<option value='RepeaterFENYE.ASPx?page=" + i.ToString() +"' selected>第" + i + "頁</option>";
}
else
{
//HtmlSelectString += "<option value=wjProduct-" + i + "-" + Menu_ID + ".html>第" + i + "頁</option>";
HtmlSelectString += "<option value='RepeaterFENYE.ASPx?page=" + i.ToString() + "'>第" + i + "頁</option>";
}
}
HtmlSelectString += "</select>";
this.Label4.Text += "<a>" + HtmlSelectString + "</a>";
}
else
{
Label4.Text = "沒有數(shù)據(jù)!";
}
}
}
注://注釋部分為url rewrite的效果。。。li返回的值為SQL查詢后所得到表中所有的記錄。。。

AspNet技術asp.net repeater手寫分頁實例代碼,轉(zhuǎn)載需保留來源!

鄭重聲明:本文版權歸原作者所有,轉(zhuǎn)載文章僅為傳播更多信息之目的,如作者信息標記有誤,請第一時間聯(lián)系我們修改或刪除,多謝。

主站蜘蛛池模板: 晋州市| 丽水市| 涡阳县| 甘孜县| 九龙城区| 论坛| 肥乡县| 屏东县| 墨脱县| 渭源县| 同德县| 门源| 三门峡市| 武陟县| 集安市| 汝州市| 湄潭县| 涟水县| 龙口市| 澎湖县| 军事| 洮南市| 电白县| 虞城县| 霍城县| 大港区| 嘉义县| 芮城县| 黄龙县| 图片| 盐边县| 莱芜市| 盐城市| 前郭尔| 茶陵县| 牙克石市| 威信县| 柏乡县| 永福县| 南溪县| 仙游县|