还有就是一个Paging属性,他的作用就是分页,输出分页的html这个属性很经典
1DotLucene搜索索引(下)DotLucene搜索索引(下)/**//// <summary>
2DotLucene搜索索引(下)    /// 开始分页
3DotLucene搜索索引(下)    /// </summary>
4DotLucene搜索索引(下)    /// <returns></returns>

5DotLucene搜索索引(下)    protected DataTable Paging
6DotLucene搜索索引(下)DotLucene搜索索引(下)    DotLucene搜索索引(下){
7DotLucene搜索索引(下)        get
8DotLucene搜索索引(下)DotLucene搜索索引(下)        DotLucene搜索索引(下){
9DotLucene搜索索引(下)           //知道了startAt,分页也很容易了,现在根据startAt得到当前是第几页,注意,现在这里的页数也是暂时从0开始的
10DotLucene搜索索引(下)            int pageNumber = (this.startAt + this.maxResults - 1) / this.maxResults;
11DotLucene搜索索引(下)             DataTable dt = new DataTable();
12DotLucene搜索索引(下)             dt.Columns.Add("html");
13DotLucene搜索索引(下)             DataRow dr = dt.NewRow();
14DotLucene搜索索引(下)            //暂时得到当前页的html连接,注意这里当真正显示页数的时候要+1
15DotLucene搜索索引(下)             dr["html"] = pagingNumberHtml(startAt,pageNumber+1,false);
16DotLucene搜索索引(下)             dt.Rows.Add(dr);
17DotLucene搜索索引(下)            //前面显示10页,如果有的话
18DotLucene搜索索引(下)            int previousPagesCount = 10;
19DotLucene搜索索引(下)            //循环把前面页的html连接插到前面去
20DotLucene搜索索引(下)            for (int i = pageNumber - 1; i >= 0 && i >= pageNumber - previousPagesCount; i--)
21DotLucene搜索索引(下)DotLucene搜索索引(下)            DotLucene搜索索引(下){
22DotLucene搜索索引(下)                 DataRow r = dt.NewRow();
23DotLucene搜索索引(下)                 r["html"] = pagingNumberHtml(i*this.maxResults,i+1,true);
24DotLucene搜索索引(下)                 dt.Rows.InsertAt(r,0);;
25DotLucene搜索索引(下)             }

26DotLucene搜索索引(下)            //后面也显示10页,如果有的话
27DotLucene搜索索引(下)            int nextPagesCount = 10;
28DotLucene搜索索引(下)            for (int i = pageNumber + 1; i <= this.pageCount && i <= pageNumber + nextPagesCount; i++)
29DotLucene搜索索引(下)DotLucene搜索索引(下)            DotLucene搜索索引(下){
30DotLucene搜索索引(下)                 DataRow r = dt.NewRow();
31DotLucene搜索索引(下)                 r["html"] = pagingNumberHtml(i*this.maxResults,i+1,true);
32DotLucene搜索索引(下)                 dt.Rows.Add(r);
33DotLucene搜索索引(下)             }

34DotLucene搜索索引(下)            //添加下一页的超级连接
35DotLucene搜索索引(下)             DataRow lastRow = dt.NewRow();
36DotLucene搜索索引(下)             lastRow["html"] = "<a href='Search.aspx?q="+this.Query+"&start="+(pageNumber+1)*this.maxResults+"'>下一页</a>";
37DotLucene搜索索引(下)             dt.Rows.Add(lastRow);
38DotLucene搜索索引(下)            return dt;
39DotLucene搜索索引(下)
40DotLucene搜索索引(下)         }

相关文章: