asp中的分页

来源:互联网 发布:异地同步看电影软件 编辑:程序博客网 时间:2024/06/02 03:12
 <webdiyer:AspNetPager ID="AspNetPager1" runat="server" Width="100%" UrlPaging="false"
                        ShowPageIndexBox="Always" PageIndexBoxType="DropDownList" TextBeforePageIndexBox="转到: "
                        FirstPageText="首页" LastPageText="末页" PrevPageText="上一页" NextPageText="下一页" HorizontalAlign="left"
                        EnableTheming="true" OnPageChanged="AspNetPager1_PageChanged">

                    </webdiyer:AspNetPager>


后端代码


    DataTable dt = BulletionAction.ReturnTable(this.UserCode, strwhere);
            AspNetPager1.RecordCount = dt.Rows.Count;
            if(dt.Rows.Count>0){
                PagedDataSource pds = new PagedDataSource();
                AspNetPager1.RecordCount = dt.Rows.Count;
                pds.AllowPaging = true;
                pds.PageSize = AspNetPager1.PageSize;
                pds.CurrentPageIndex = AspNetPager1.CurrentPageIndex - 1;
                pds.DataSource = dt.DefaultView;
                this.GridView1.DataSource = pds;
                this.GridView1.DataBind();
            }
          
        }

原创粉丝点击