1 DataSet ds = new DataSet();
 2 ds.ReadXml("d:\\sample.xml");
 3 
 4 PagedDataSource pds = new PagedDataSource();
 5 pds.DataSource = ds.Tables[0].DefaultView;
 6 pds.AllowPaging = true;
 7 pds.PageSize = 5;
 8 
 9 int CurrentPage = 1;
10 if (Request.QueryString["page"!= null)
11 {
12     CurrentPage = Convert.ToInt32(Request.QueryString["page"]);
13 }
14 else
15 {
16     CurrentPage = 1;
17 }
18 
19 if (pds.PageCount < CurrentPage)
20 {
21     return;
22 }
23 
24 pds.CurrentPageIndex = CurrentPage - 1
25 lblCurrentPage.Text = CurrentPage.ToString();//显示当前页
26 lblPageCount.Text = pds.PageCount.ToString();//显示总页数
27 
28 if (!pds.IsFirstPage)
29 {//设定页面导航
30     lnkPrev.NavigateUrl = Request.CurrentExecutionFilePath
31     + "?page=" + Convert.ToInt32(CurrentPage - 1);
32     lnkFirst.NavigateUrl = Request.CurrentExecutionFilePath
33     + "?page=1";
34 }
35 
36 if (!pds.IsLastPage)
37 {//设定页面导航
38     lnkNext.NavigateUrl = Request.CurrentExecutionFilePath
39     + "?page=" + Convert.ToInt32(CurrentPage + 1);
40     lnkLast.NavigateUrl = Request.CurrentExecutionFilePath
41     + "?page=" + pads.PageCount;
42 }
43 
44 dataList.DataSource = pds;
45 dataList.DataBind();
46 ds.Dispose();
posted on 2006-04-21 16:34  宝气狗  阅读(344)  评论(0)    收藏  举报