晓风拂月的专栏

<a target="_blank" href="http://wpa.qq.com/msgrd?v=3&uin=715733768&site=qq...

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 null server div
个人分类: .Net
想对作者说点什么? 我来说一句

没有更多推荐了,返回首页

不良信息举报

AspNet pager 分页的基本用法

最多只允许输入30个字

加入CSDN,享受更精准的内容推荐,与500万程序员共同成长!
关闭
关闭