GridView中使用分页控件

时间:2023-12-11 09:13:32

前台:导入<%@ Register assembly="AspNetPager" namespace="Wuqi.Webdiyer" tagprefix="webdiyer" %>

引用:<div class="pages">
             <webdiyer:AspNetPager ID="AspNetPager1" runat="server" PageSize="15"
                     onpagechanged="AspNetPager1_PageChanged"
                 CustomInfoHTML="共%PageCount%页,当前为第%CurrentPageIndex%页,每页%PageSize%条"
                 FirstPageText="首页" LastPageText="尾页" NextPageText="下一页" PrevPageText="上一页"
                 ShowCustomInfoSection="Left">
                     </webdiyer:AspNetPager>
        </div>

可以自定义样式

后台:调用及绑定

public void BandRuleFlow() {

DataSet ds = OPA_RuleFlow.GetAllRuleFlowList(opa_ruleflow);
        count = ds.Tables[0].Rows.Count;
        PagedDataSource pds = new PagedDataSource();
        pds.AllowPaging = true;
        pds.DataSource = ds.Tables[0].DefaultView;
        pds.CurrentPageIndex = AspNetPager1.CurrentPageIndex - 1;
        AspNetPager1.RecordCount = ds.Tables[0].Rows.Count;
        pds.PageSize = AspNetPager1.PageSize;
        this.RepeaterRuleFlow.DataSource = pds;
        this.RepeaterRuleFlow.DataBind();
    
    }