在SL中提供了数据分页控件,DataPager控件,可以很方便的使用其为我们的数据进行分页。相对于Asp.net中的第三方分页控件,如Dev控件或是Rad控件,就分页控件来说,SL走在ASP。NET前面,MS自家出的DataPager更有吸引力。
几个重要的属性
Vertical/HorizontalContentAlignment:分页控件内容在分页控件中的对齐方式
只读属性:
CanChangePage:能否分页[只读]
CanMoveToFirstPage:能否移动到第一页[只读]
CanMoveToLastPage:能否移动到最后页[只读]
CanMoveToNextPage:能否移动到下一页[只读]
CanMoveToPreviousPage:能否移动到上一页[只读]
ItemCount:总记录数[只读]
PageCount:总页数[只读]
DisplayMode:显示模式
FirstLastNumeric
FirstLastPreviousNext
FirstLastPreviousNextNumeric
Numeric
PreviousNext
PreviousNextNumeric
可以从上面和文字和下图就可以知道大约每种模式会是什么样子
NumericButtonCount:设置中Numeric的数量
PageIndex:设置当前页
PageSize:设置每页大小
几个重要事件
PageIndexChanging:当前页改变时发生
PageIndexChanged:当前页改变后发生
基本用法
1 2 3 4 5 6 7 8 9 10 |
//数据源
char[] dt = "Fhnfsuihxjkvjkwhuehfsxhfkljspfjqifjohfiwhfioshfioqhwiofhsdiofhiowhfiosdhf".ToCharArray();
//使用 PagedCollectionView 可为实现 IEnumerable 接口的任何集合提供分组、排序、筛选和分页功能。
PagedCollectionView pcv = new PagedCollectionView(dt);
this.datapager.NumericButtonCount = 10;
this.datapager.DisplayMode = PagerDisplayMode.FirstLastPreviousNextNumeric;
this.datapager.Source = pcv;
|