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>

你可能感兴趣的:(object,server,null,div)