国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > .NET > 正文

asp.net repeater手寫分頁實(shí)例代碼

2024-07-10 13:20:09
字體:
供稿:網(wǎng)友

復(fù)制代碼 代碼如下:


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>當(dāng)前第<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查詢后所得到表中所有的記錄。。。

發(fā)表評論 共有條評論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 体育| 二手房| 哈巴河县| 华池县| 柘荣县| 天峨县| 乐陵市| 鄂伦春自治旗| 漾濞| 无极县| 南城县| 东兰县| 修武县| 柯坪县| 宣威市| 北宁市| 平阴县| 清新县| 吉木乃县| 江孜县| 齐齐哈尔市| 简阳市| 锦州市| 金坛市| 永靖县| 宁晋县| 开平市| 宣威市| 隆回县| 长兴县| 文成县| 宁海县| 屏南县| 措勤县| 台州市| 全州县| 台山市| 兴山县| 大足县| 琼海市| 新绛县|