复制代码 代码如下:
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 = "没有数据!";
}
}
}
注://注释部分为url rewrite的效果。。。li返回的值为SQL查询后所得到表中所有的记录。。。
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 = "没有数据!";
}
}
}
注://注释部分为url rewrite的效果。。。li返回的值为SQL查询后所得到表中所有的记录。。。
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件!
如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
桃源资源网 Design By www.nqtax.com
暂无“asp.net repeater手写分页实例代码”评论...
RTX 5090要首发 性能要翻倍!三星展示GDDR7显存
三星在GTC上展示了专为下一代游戏GPU设计的GDDR7内存。
首次推出的GDDR7内存模块密度为16GB,每个模块容量为2GB。其速度预设为32 Gbps(PAM3),但也可以降至28 Gbps,以提高产量和初始阶段的整体性能和成本效益。
据三星表示,GDDR7内存的能效将提高20%,同时工作电压仅为1.1V,低于标准的1.2V。通过采用更新的封装材料和优化的电路设计,使得在高速运行时的发热量降低,GDDR7的热阻比GDDR6降低了70%。