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);
    }


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

tiz198183

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值