这几天在写个分页程序,疑惑的是分页的时候按了第二页后没有数据显示,.net跟踪到第二页时pagedatasource的count有数字的,但是datasourcecount为0了
而且我想做个能循环输出页码选择点击的链接,不知道该用哪个服务器端控件比较好,望各位指教
 public partial class list : System.Web.UI.Page
    {
        PagedDataSource PDS = new PagedDataSource();
        protected void Page_Load(object sender, EventArgs e)
        {
            PageDS();
        }
     
          private void PageDS()
          {
            string district = Request.Form["District"];
            string city = Request.Form["City"];
            if (district != "" && city != "")
            {               
                string connStr = ConfigurationManager.AppSettings["ConnectionString"].ToString();
                SqlConnection conn = new SqlConnection();
                DataTable dt = new DataTable();
                conn.ConnectionString = connStr;
                conn.Open();
                try
                {
                SqlDataAdapter sda=new SqlDataAdapter("select * from res_list where res_city_id = '" + city + "'and res_district='" + district + "'",connStr);
                sda.Fill(dt);
                 
                PDS.DataSource = dt.DefaultView;
                PDS.AllowPaging = true;
                PDS.PageSize = 5;
                int TotalCount = PDS.PageCount;                
                int CurPage;
               
                if (Request.QueryString["Page"] != null)
                {
                    CurPage = Convert.ToInt32(Request.QueryString["Page"]);
                }
                else
                {
                    CurPage = 1;
                }
                PDS.CurrentPageIndex = CurPage - 1;
                ResAddress.DataSource = PDS;
                if (!PDS.IsFirstPage)
                {
                    this.btback.Enabled = true;
                    this.btnext.Enabled = false;
                    btback.NavigateUrl = Request.CurrentExecutionFilePath + "?Page=" + Convert.ToString(CurPage - 1);
                   
                }
                if (!PDS.IsLastPage)
                {
                    this.btback.Enabled = false;
                    this.btnext.Enabled = true;
                    btnext.NavigateUrl = Request.CurrentExecutionFilePath + "?Page=" + Convert.ToString(CurPage + 1);
                    
                }
                                   
     
                }
                catch (Exception ex)
                {
                    Response.Write(ex.ToString());
                }
                finally
                {
                    if (conn.State != ConnectionState.Closed)
                        conn.Close();
                }
                
                ResAddress.DataBind();
            }
        }
 
      
              }