AspNetPager 分页 用法

<%@ Page Language="C#" MasterPageFile="MasterPage.master" AutoEventWireup="true" CodeFile="ZpList.aspx.cs" Inherits="ZpList" Title="无标题页" %>
<%@ Register Assembly="AspNetPager" Namespace="Wuqi.Webdiyer" TagPrefix="webdiyer" %>
<asp:Content ID="Content1" ContentPlaceHolderID="headHide" Runat="Server"><link href="css/list.css" rel="stylesheet" type="text/css" /><link href="css/css.css" rel="stylesheet" type="text/css" />
<script type="text/javascript">function ClickDel(vid){if(confirm("确定要删除吗?")){window.location.href="ZpDel.aspx?id="+vid;}}
</script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentHide" Runat="Server"><div class="main">
<h3>企业招聘列表</h3>
<div>
<table width="100%" cellpadding="10px" cellspacing="2px">
<tr style="height:20px"><td><h4>招聘职位</h4></td><td><h4>招聘人数</h4></td><td><h4>发布时间</h4></td><td><h4>操作</h4></td></tr><asp:Repeater ID="RepList" runat="server"><ItemTemplate><tr style="height:20px"><td><%# GetLb(Eval("PositionTitle").ToString())%> -> <%# GetLb(Eval("PositionTitle1").ToString())%></td><td><%# Eval("PeopleNumber")%></td><td><%# Convert.ToDateTime(Eval("PostDate")).ToShortDateString()%></td><td><a href="ZpEdit.aspx?id=<%#Eval("id")%>">编辑</a> | <a οnclick="ClickDel(<%#Eval("id")%>)">删除</a></td></tr></ItemTemplate></asp:Repeater>
</table>
</div><div style="clear:both"></div><div style="height:20px"></div><webdiyer:AspNetPager ID="AspNetPager1" runat="server" AlwaysShow="True" Font-Size="12px"PageSize="15" CustomInfoHTML="第%CurrentPageIndex%页,共%PageCount%页,每页%PageSize%条"ShowPageIndex="false" PageIndexBoxType="DropDownList" OnPageChanged="AspNetPager1_PageChanged"ShowCustomInfoSection="Left" ShowPageIndexBox="Always" NextPageText="下一页" PrevPageText="上一页" ShowNavigationToolTip="false" SubmitButtonText="Go" TextAfterPageIndexBox="页" TextBeforePageIndexBox="转到" FirstPageText="首页" LastPageText="尾页"></webdiyer:AspNetPager><div style="clear:both"></div>
</div>
</asp:Content>

public partial class ZpList : System.Web.UI.Page
{protected  int zpCount;//总记录数protected void Page_Load(object sender, EventArgs e){if (!Page.IsPostBack){zpCount = ZpInfoBLL.Countzp();//总记录GetList();//分页绑定}}protected void GetList(){if (zpCount != 0){if (Convert.ToString(Request.QueryString["IntPageIndex"]) != null){AspNetPager1.CurrentPageIndex = Convert.ToInt32(this.Request["IntPageIndex"].ToString());//当前页}AspNetPager1.RecordCount = zpCount; //总记录this.RepList.DataSource = ZpInfoBLL.GetZpList( AspNetPager1.PageSize * (AspNetPager1.CurrentPageIndex - 1), AspNetPager1.PageSize);this.RepList.DataBind();}}protected void AspNetPager1_PageChanged(object sender, EventArgs e){GetList();}}

类:

    /// <summary>/// 分页记录总数/// </summary>/// <returns></returns>public static int CountLb(){StringBuilder strSql = new StringBuilder();strSql.Append("select count(*) from lb");Object[] objectvalues = new Object[] {};return Convert.ToInt32(SqlHelper.ExecuteScalar(strSql.ToString(), objectvalues));}/// <summary>/// 分页/// </summary>/// <param name="UserId"></param>/// <param name="startRecord"></param>/// <param name="maxrecords"></param>/// <returns></returns>public static DataSet GetLbList(int startRecord, int maxrecords){StringBuilder strSql = new StringBuilder();strSql.Append("select *");strSql.Append(" from lb");strSql.Append(" order by id desc");Object[] objectvalues = new Object[] { };return SqlHelper.Fill(startRecord, maxrecords, "aa", strSql.ToString(), objectvalues);}