AspNet pager 分页的基本用法

 

cs 页面

public void BindData()
        {
            DataTable dt = new DataTable();
            if (!string.IsNullOrEmpty(ViewState["strWhere"].ToString()))
            {
                strWhere = ViewState["strWhere"].ToString();
            }
            nTotleCount = Global.busLogicInner.GTalCount(strWhere, tableName, "NewsID");
            dt = Global.busLogicInner.GDateReturnTable(0, strWhere, tableName, "*");
            if (dt != null)
            {
                this.divNoData.Style["display"] = "none";
                PagedDataSource pds = new PagedDataSource();
                pds.AllowPaging = true;
                pds.DataSource = dt.DefaultView;
                pds.PageSize = Pager.PageSize = pageSize;
                Pager.RecordCount = nTotleCount;
                pds.CurrentPageIndex = Pager.CurrentPageIndex - 1;//当前页索引.
                pds.PageSize = Pager.PageSize;//每页要显示的记录条数.           
                this.BondRpt.DataSource = pds;
                this.BondRpt.DataBind();
                AddCustomText();
            }
            else
            {
                this.BondRpt.DataSource = null;
                this.divNoData.Style["display"] = "block";
                this.divNoData.InnerHtml = "没有找到相关数据";
            }

        }

        protected void Pager_PageChanged(object sender, EventArgs e)
        {
            BindData();
        }

        protected void Pager_PageChanging(object src, Wuqi.Webdiyer.PageChangingEventArgs e)
        {
            this.Pager.CurrentPageIndex = e.NewPageIndex;
            BindData();
        }

        /// <summary>
        /// 添加相关文字说明
        /// </summary>
        public void AddCustomText()
        {
            Pager.CustomInfoHTML = "共找到:<font color=/"red/"><b>" + Pager.RecordCount.ToString() + "</b></font>篇报告&nbsp;&nbsp;&nbsp;";
            Pager.CustomInfoHTML += "当前[<font color=/"red/"><b>" + Pager.CurrentPageIndex.ToString() + "</b></font>/";
            Pager.CustomInfoHTML += "<font color=/"blue/"><b>" + Pager.PageCount.ToString() + "</b></font>]页&nbsp;&nbsp;&nbsp;";
            Pager.CustomInfoHTML += "每页显示 <font color=/"blue/"><b>" + Pager.PageSize + "</b></font>条记录&nbsp;&nbsp;&nbsp;";
        }

 

aspx 页面

 <webdiyer:AspNetPager ID="Pager" runat="server" AlwaysShow="True" FirstPageText="首页"
                LastPageText="尾页" NextPageText="下一页" OnPageChanged="Pager_PageChanged" OnPageChanging="Pager_PageChanging"
                PageIndexBoxType="DropDownList" PrevPageText="上一页"
                CustomInfoTextAlign="Right" Direction="LeftToRight" Font-Bold="True"
                Font-Size="Small" Height="15px" HorizontalAlign="Right" LayoutType="Div"
                PageSize="25" ShowCustomInfoSection="Right" ShowNavigationToolTip="True">
            </webdiyer:AspNetPager>

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值