分页控件 代码值得收藏

前台样式代码

<webdiyer:AspNetPagerid="AspNetPager1"runat="server"OnPageChanged="AspNetPager1_PageChanged"
AlwaysShow="true"FirstPageText="首页"LastPageText="尾页"NextPageText="下一页"PrevPageText="上一页"
NumericButtonCount="6"CssClass="paginator"CurrentPageButtonClass="cpd">
</webdiyer:AspNetPager>

C#代码
protectedvoidBindData()
{
PagedDataSource pds =newPagedDataSource();
//用表格视图作为PagedDataSource的数据源
pds.DataSource=this.StrToDataTable().DefaultView;
pds.AllowPaging=true;
pds.PageSize=AspNetPager1.PageSize=4;
AspNetPager1.RecordCount= pds.DataSourceCount;//改变当前索引页号(相当重要)/////////////

pds.CurrentPageIndex=AspNetPager1.CurrentPageIndex-1;
//将pds绑定到Repeater控件上
parentRepeater.DataSource= pds;
parentRepeater.DataBind();
}
 
posted @ 2012-09-21 15:32  yuloe2012  阅读(246)  评论(0编辑  收藏  举报