无语了,这个也能问的出来啊。。。。。下面的是java的代码,几乎是复制过去就能用。。。
/**
* 分页方法
*@returnType:List
使用linq:
//页数
int PageNum=2;
//每一页多少条数据
int Record=5;
//pageList是某一页的数据
var pageList=list.Skip(Record * (PageNum - 1)).Take(Record);
跟是bs和cs是无关的
用一个全局变量记录list下标可以实现吧
代码如下:
1 public partial class XTeacherFinder
2 {
3 private string m_TeacherId = string.Empty;
4
5 public string TeacherId
6 {
7 get { return m_TeacherId; }
8 set { this.m_TeacherId = value; }
9 }
10
11 private string m_TeacherName = string.Empty;
12
13 public string TeacherName
14 {
15 get { return this.m_TeacherName; }
16 set { this.m_TeacherName = value; }
17 }
18
19 public XTeacherFinder()
20 {
21
22 }
23
24 ///
25 /// 通过ID查找
26 ///
27 ///
28 ///
29 public bool FindTeacherById(XTeacher teacher)
30 {
31 return m_TeacherId == teacher.Id;
32 }
33
34 ///
35 /// 通过名称查找
36 ///
37 ///
38 ///
39 public bool FindTeacherByName(XTeacher teacher)
40 {
41 return m_TeacherName == teacher.Name;
42 }
43
44 ///
45 /// 通过ID和名称查找
46 ///
47 ///
48 ///
49 public bool FindTeacherByIdAndName(XTeacher teacher)
50 {
51 return (m_TeacherName == teacher.Name && m_TeacherId == teacher.Id);
52 }
53 }
int pageNum=1; //当前页
int ListPageIndex=0; //List中的下标
ListPageIndex=(pageNum-1)*5; //当前页第一条的下标
for(int i=0;i<5;i++)
{
Console.WriteLine(list[ListPageIndex+i].toString());
}
PS:你每次翻页,需要传入 PageSize
下一页就是 +1
上一页就是 -1