/// <summary>
/// 翻页绑定
/// </summary>
/// <param name="acc">元数据</param>
/// <param name="pgid">表示页码的request参数</param>
/// <param name="pSize">每页项目数</param>
/// <param name="lab">显示翻页按钮的空间</param>
/// <param name="pgr">需要绑定的空间</param>
/// <param name="acct">其他参数</param>
public void Bind(DataSet acc, string pgid, int pSize, Label lab, Repeater pgr, string acct)
{
try
{
pds.DataSource = acc.Tables["Sun"].DefaultView;
pds.AllowPaging = true;
pds.PageSize = pSize;
int cpIndex = 1;
if (!String.IsNullOrEmpty(pgid)) Int32.TryParse(pgid, out cpIndex);
if (cpIndex < 1) cpIndex = 1;
if (cpIndex > pds.PageCount) cpIndex = pds.PageCount;
lab.Text = WritePage(pgid, acct); //画出翻页数字
pds.CurrentPageIndex = cpIndex - 1;
pgr.DataSource = pds;
pgr.DataBind();
}
catch { }//{ Message.Error("系统出错请联系管理员!"); }
}
/// <summary>
/// 输出分页按钮
/// </summary>
/// <param name="pid">表示页码的request参数</param>
/// <param name="acct">其他参数</param>
/// <returns></returns>
public string WritePage(string pid, string acct)
{
string page = "";
int pageID = 1;
if (!String.IsNullOrEmpty(pid)) Int32.TryParse(pid, out pageID);
if (pageID < 1) pageID = 1;
if (pageID > pds.PageCount) pageID = pds.PageCount;
page = "<a href='?" + acct + "pageID=1'><</a>\r";
for (int i = 1; i <= pds.PageCount; i++)
{
if (i == pageID)
{
page += "<span class='current'>" + Convert.ToString(i) + "</span>\r";
}
else
{
page += "<a href='?" + acct + "pageID=" + Convert.ToString(i) + "'>" + Convert.ToString(i) + "</a>\r";
}
}
page += "<a href='?" + acct + "pageID=" + pds.PageCount.ToString() + "'>></a>\r";
return page;
}
以上方法为本人实际项目源码,分页标签CSS暂未公布,其实也很简单的