Repeater没有自带的分页功能,于是用了AspNetPager分布组件,代码如下:
var sWhere = string.Format( " Serviceid={0} ", sId); var mDataTable = DAL.Log.GetList(sWhere).Tables[ 0]; AspNetPager1.RecordCount = mDataTable.Rows.Count; var pds = new PagedDataSource { DataSource = mDataTable.DefaultView, CurrentPageIndex = AspNetPager1.CurrentPageIndex - 1, PageSize = AspNetPager1.PageSize, AllowPaging = true }; Repeater1.DataSource = pds; Repeater1.DataBind();
AspNetPage的数据源连的是DataTable