北极之冰

DataList分页
DataSet   myDataSet   =   new   DataSet();  
                  myDataSet   =   myBUProduct.GetOwnList(myBaseDBCon);  
                  //this.lstNewProAll.DataSource   =   myDataSet.Tables[0];  
                  //this.lstNewProAll.DataBind();  
                  try  
                  {  
                          //创建分页类  
                          PagedDataSource   objPage   =   new   PagedDataSource();  
                          //设置数据源  
                          objPage.DataSource   =   myDataSet.Tables[0].DefaultView;  
                          //允许分页  
                          objPage.AllowPaging   =   true;  
                          //设置每页显示的项数  
                          objPage.PageSize   =   10;  
                          //定义变量用来保存当前页索引  
                          int   CurPage;  
                          //判断是否具有页面跳转的请求  
                          if   (Request.QueryString["Page"]   !=   null)  
                                  CurPage   =   Convert.ToInt32(Request.QueryString["Page"]);  
                          else  
                                  CurPage   =   1;  
                          //设置当前页的索引  
                          objPage.CurrentPageIndex   =   CurPage   -   1;  
                          //显示状态信息  
                          lblCurPage.Text   =   "当前页:第"   +   CurPage.ToString()   +   "页";  
                          //如果当前页面不是首页  
                          if   (!objPage.IsFirstPage)  
                                  //定义"上一页"超级链接的URL为:当前执行页面的虚拟路径,并传递下一页面的索引值  
                                  lnkPrev.NavigateUrl   =   Request.CurrentExecutionFilePath   +   "?Page="   +   Convert.ToString(CurPage   -   1);  
                          //如果当前页面不是最后一页  
                          if   (!objPage.IsLastPage)  
                                  //定义"下一页"超级链接的URL为:当前执行页面的虚拟路径,并传递下一页面的索引值  
                                  lnkNext.NavigateUrl   =   Request.CurrentExecutionFilePath   +   "?Page="   +   Convert.ToString(CurPage   +   1);  
   
                          //进行数据绑定  
                          lstNewProAll.DataSource   =   objPage;  
                          lstNewProAll.DataBind();  
                  }  
                  catch   (Exception   error)  
                  {  
                          //输出异常信息  
                          Response.Write(error.ToString());  
                  }

posted on 2009-05-08 09:53  北极之冰  阅读(194)  评论(0)    收藏  举报