Repeater 分页 像GV 1 2 3页一样 同上 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 http://www.webdiyer.com/AspNetPager/demo/PagedRepeater/default.aspx 我要代码形式的 PagedDataSource 类的 <%@ Page Language="C#" AutoEventWireup="true" CodeFile="repeaterPDS.aspx.cs" Inherits="repeaterPDS" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml" ><head runat="server"> <title>无标题页</title></head><body> <form id="form1" runat="server"> <div> <asp:Repeater ID='rp' runat="server"> <ItemTemplate> <%#Eval("ID")%> <%#Eval("Name") %> </ItemTemplate> </asp:Repeater> <br> <asp:Literal ID="lit" runat="server"></asp:Literal> </div> </form></body></html> using System;using System.Data;using System.Configuration;using System.Collections;using System.Web;using System.Web.Security;using System.Web.UI;using System.Web.UI.WebControls;using System.Web.UI.WebControls.WebParts;using System.Web.UI.HtmlControls;public partial class repeaterPDS : System.Web.UI.Page{ protected DataTable getDataTable() { System.Data.DataTable dt = new System.Data.DataTable(); System.Data.DataRow dr; dt.Columns.Add(new System.Data.DataColumn("ID", typeof(System.Int32))); dt.Columns.Add(new System.Data.DataColumn("Name", typeof(System.String))); dr = dt.NewRow(); dr[0] = 1; dr[1] = "小明"; dt.Rows.Add(dr); dr = dt.NewRow(); dr[0] = 2; dr[1] = "小强"; dt.Rows.Add(dr); dr = dt.NewRow(); dr[0] = 3; dr[1] = "小张"; dt.Rows.Add(dr); dr = dt.NewRow(); dr[0] = 4; dr[1] = "小李"; dt.Rows.Add(dr); dr = dt.NewRow(); dr[0] = 5; dr[1] = "小关"; dt.Rows.Add(dr); return dt; } private string getPageIndex(int count) { string pageIndex = ""; for (int i = 0; i < count; i++) { pageIndex += "<a href='repeaterPDS.aspx?pageIndex=" + i + "'>" + (i + 1) + "</a>"; } return pageIndex; } protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { int currentPageIndex; int.TryParse(string.IsNullOrEmpty(Request.QueryString["pageIndex"]) ? "" : Request.QueryString["pageIndex"],out currentPageIndex); PagedDataSource pds = new PagedDataSource(); pds.DataSource = getDataTable().DefaultView; pds.AllowPaging = true; pds.PageSize = 1; pds.CurrentPageIndex = currentPageIndex; rp.DataSource = pds; rp.DataBind(); lit.Text = getPageIndex(pds.PageCount); } }} 像DATALIST 一样分可以么?asp.net 技术交流群: 40400738 using System;using System.Data;using System.Configuration;using System.Collections;using System.Web;using System.Web.Security;using System.Web.UI;using System.Web.UI.WebControls;using System.Web.UI.WebControls.WebParts;using System.Web.UI.HtmlControls;public partial class repeaterPDS : System.Web.UI.Page{ protected DataTable getDataTable() { System.Data.DataTable dt = new System.Data.DataTable(); System.Data.DataRow dr; dt.Columns.Add(new System.Data.DataColumn("ID", typeof(System.Int32))); dt.Columns.Add(new System.Data.DataColumn("Name", typeof(System.String))); dr = dt.NewRow(); dr[0] = 1; dr[1] = "小明"; dt.Rows.Add(dr); dr = dt.NewRow(); dr[0] = 2; dr[1] = "小强"; dt.Rows.Add(dr); dr = dt.NewRow(); dr[0] = 3; dr[1] = "小张"; dt.Rows.Add(dr); dr = dt.NewRow(); dr[0] = 4; dr[1] = "小李"; dt.Rows.Add(dr); dr = dt.NewRow(); dr[0] = 5; dr[1] = "小关"; dt.Rows.Add(dr); return dt; } private string getPageIndex(int count) { string pageIndex = ""; for (int i = 0; i < count; i++) { pageIndex += "<a href='repeaterPDS.aspx?pageIndex=" + i + "' style='color: blue;text-decoration:none' >" + (i + 1) + "</a>"; pageIndex += " "; } return pageIndex; } protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { int currentPageIndex; int.TryParse(string.IsNullOrEmpty(Request.QueryString["pageIndex"]) ? "" : Request.QueryString["pageIndex"],out currentPageIndex); PagedDataSource pds = new PagedDataSource(); pds.DataSource = getDataTable().DefaultView; pds.AllowPaging = true; pds.PageSize = 1; pds.CurrentPageIndex = currentPageIndex; rp.DataSource = pds; rp.DataBind(); lit.Text = getPageIndex(pds.PageCount); lit.Text += "当前页为第" + ((currentPageIndex == 0) ? 1 : currentPageIndex + 1) + "页"; } }} protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { int currentPageIndex; int.TryParse(string.IsNullOrEmpty(Request.QueryString["pageIndex"]) ? "0" : Request.QueryString["pageIndex"],out currentPageIndex); PagedDataSource pds = new PagedDataSource(); pds.DataSource = getDataTable().DefaultView; pds.AllowPaging = true; pds.PageSize = 1; pds.CurrentPageIndex = currentPageIndex; rp.DataSource = pds; rp.DataBind(); lit.Text = getPageIndex(pds.PageCount); lit.Text += "当前页为第" + (currentPageIndex + 1) + "页"; } } drag and drop功能实现,求教! 求个正则,匹配css样式 在线等:分不够加:c# asp.net web水晶报表图表,ie可以看到,但是打印是红叉,怎么回事情? 哪位有ip数据库呢?或者知道webService提供根据ip解释具体地址的? 这种写法对不? 如何获得当前显示的网页在虚拟主机上的物理路径 HyperLink 问题 MVC、JS实现Html页面指定区域导出WORD、Excel 请问如何启用ASP。NET页面的调试? 谁能告诉我一个好的免费asp.net空间么? 求助水晶报表的发布 lable控件的text字符插入sql的问题
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="repeaterPDS.aspx.cs" Inherits="repeaterPDS" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>无标题页</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Repeater ID='rp' runat="server">
<ItemTemplate>
<%#Eval("ID")%>
<%#Eval("Name") %>
</ItemTemplate>
</asp:Repeater>
<br>
<asp:Literal ID="lit" runat="server"></asp:Literal>
</div>
</form>
</body>
</html>
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;public partial class repeaterPDS : System.Web.UI.Page
{
protected DataTable getDataTable()
{ System.Data.DataTable dt = new System.Data.DataTable();
System.Data.DataRow dr;
dt.Columns.Add(new System.Data.DataColumn("ID", typeof(System.Int32)));
dt.Columns.Add(new System.Data.DataColumn("Name", typeof(System.String)));
dr = dt.NewRow();
dr[0] = 1;
dr[1] = "小明";
dt.Rows.Add(dr);
dr = dt.NewRow();
dr[0] = 2;
dr[1] = "小强";
dt.Rows.Add(dr);
dr = dt.NewRow();
dr[0] = 3;
dr[1] = "小张";
dt.Rows.Add(dr);
dr = dt.NewRow();
dr[0] = 4;
dr[1] = "小李";
dt.Rows.Add(dr);
dr = dt.NewRow();
dr[0] = 5;
dr[1] = "小关";
dt.Rows.Add(dr);
return dt;
} private string getPageIndex(int count)
{
string pageIndex = "";
for (int i = 0; i < count; i++)
{
pageIndex += "<a href='repeaterPDS.aspx?pageIndex=" + i + "'>" + (i + 1) + "</a>";
}
return pageIndex;
} protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
int currentPageIndex;
int.TryParse(string.IsNullOrEmpty(Request.QueryString["pageIndex"]) ? "" : Request.QueryString["pageIndex"],out currentPageIndex); PagedDataSource pds = new PagedDataSource();
pds.DataSource = getDataTable().DefaultView;
pds.AllowPaging = true;
pds.PageSize = 1;
pds.CurrentPageIndex = currentPageIndex;
rp.DataSource = pds;
rp.DataBind();
lit.Text = getPageIndex(pds.PageCount);
}
}
}
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;public partial class repeaterPDS : System.Web.UI.Page
{
protected DataTable getDataTable()
{ System.Data.DataTable dt = new System.Data.DataTable();
System.Data.DataRow dr;
dt.Columns.Add(new System.Data.DataColumn("ID", typeof(System.Int32)));
dt.Columns.Add(new System.Data.DataColumn("Name", typeof(System.String)));
dr = dt.NewRow();
dr[0] = 1;
dr[1] = "小明";
dt.Rows.Add(dr);
dr = dt.NewRow();
dr[0] = 2;
dr[1] = "小强";
dt.Rows.Add(dr);
dr = dt.NewRow();
dr[0] = 3;
dr[1] = "小张";
dt.Rows.Add(dr);
dr = dt.NewRow();
dr[0] = 4;
dr[1] = "小李";
dt.Rows.Add(dr);
dr = dt.NewRow();
dr[0] = 5;
dr[1] = "小关";
dt.Rows.Add(dr);
return dt;
} private string getPageIndex(int count)
{
string pageIndex = "";
for (int i = 0; i < count; i++)
{
pageIndex += "<a href='repeaterPDS.aspx?pageIndex=" + i + "' style='color: blue;text-decoration:none' >" + (i + 1) + "</a>";
pageIndex += " ";
}
return pageIndex;
} protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
int currentPageIndex;
int.TryParse(string.IsNullOrEmpty(Request.QueryString["pageIndex"]) ? "" : Request.QueryString["pageIndex"],out currentPageIndex); PagedDataSource pds = new PagedDataSource();
pds.DataSource = getDataTable().DefaultView;
pds.AllowPaging = true;
pds.PageSize = 1;
pds.CurrentPageIndex = currentPageIndex;
rp.DataSource = pds;
rp.DataBind();
lit.Text = getPageIndex(pds.PageCount);
lit.Text += "当前页为第" + ((currentPageIndex == 0) ? 1 : currentPageIndex + 1) + "页";
}
}
}
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
int currentPageIndex;
int.TryParse(string.IsNullOrEmpty(Request.QueryString["pageIndex"]) ? "0" : Request.QueryString["pageIndex"],out currentPageIndex); PagedDataSource pds = new PagedDataSource();
pds.DataSource = getDataTable().DefaultView;
pds.AllowPaging = true;
pds.PageSize = 1;
pds.CurrentPageIndex = currentPageIndex;
rp.DataSource = pds;
rp.DataBind();
lit.Text = getPageIndex(pds.PageCount);
lit.Text += "当前页为第" + (currentPageIndex + 1) + "页";
}
}