日期:2014-05-18  浏览次数:20462 次

repeater中的翻页问题请教,急?
设定两个标签“学习”“生活“ 触发其中一个时,repeater分页显示。问题:1、但每个类只能在当前页有效,一翻页就失去了分类?2、翻页后无法到另一个分类,例如:”学习“标签下,翻页后再触发”生活“的标签,repeater无法显示该类。

代码如下:
 protected void Learning_Click(object sender, ImageClickEventArgs e)
  {
  Learning.ImageUrl = "~/memberpage/blog/images/label/label1_selected.gif";
  life.ImageUrl = "~/memberpage/blog/images/label/label2_unselected.gif";
  //-------------------------------------//
  ///------------------------------------Tag变色--------------------------------///
  SqlConnection sqlcon = new SqlConnection("Data Source=(local);Initial Catalog=985;Persist Security Info=True;User ID=985admin;Password=985admin");
  SqlDataAdapter sqlcom = new SqlDataAdapter("select ArticleNumber,Title,SUBSTRING(Content,0,100) as Content, Type,Status from Blog_Article where Type='学习'order by Create_date desc", sqlcon);
  DataSet ds = new DataSet();
  sqlcom.Fill(ds);


  PagedDataSource pds = new PagedDataSource();
  pds.DataSource = ds.Tables[0].DefaultView;
  pds.AllowPaging = true;
  pds.PageSize = 4;

  int CurPage;
  if (Request.QueryString["Page"] != null)
  CurPage = Convert.ToInt32(Request.QueryString["Page"]);
  else
  CurPage = 1;

  pds.CurrentPageIndex = CurPage - 1;
  Label3.Text = "当前页:" + CurPage.ToString();

  if (!pds.IsFirstPage)
  HyperLink2.NavigateUrl = Request.CurrentExecutionFilePath + "?Page=" + Convert.ToString(CurPage - 1);

  if (!pds.IsLastPage)
  HyperLink3.NavigateUrl = Request.CurrentExecutionFilePath + "?Page=" + Convert.ToString(CurPage + 1);

  Repeater1.DataSource = pds;
  Repeater1.DataBind(); 

  }
   
  protected void life_Click(object sender, ImageClickEventArgs e)
  {
  life.ImageUrl = "~/memberpage/blog/images/label/label2_selected.gif";
  Learning.ImageUrl = "~/memberpage/blog/images/label/label1_unselected.gif";
  //-------------------------------------// 
  //----------------------------Tag变色------------------------------------------//
  SqlConnection sqlcon = new SqlConnection("Data Source=(local);Initial Catalog=985;Persist Security Info=True;User ID=985admin;Password=985admin");
  SqlDataAdapter sqlcom = new SqlDataAdapter("select ArticleNumber,Title,SUBSTRING(Content,0,100) as Content, Type,Status from Blog_Article where Type='生活'order by Create_date desc", sqlcon);
  DataSet ds = new DataSet();
  sqlcom.Fill(ds);
   
  PagedDataSource pds = new PagedDataSource();
  pds.DataSource = ds.Tables[0].DefaultView;
  pds.AllowPaging = true;
  pds.PageSize = 4;

  int CurPage;
  if (Request.QueryString["Page"] != null)
  CurPage = Convert.ToInt32(Request.QueryString["Page"]);
  else
  CurPage = 1;

  pds.CurrentPageIndex = CurPage - 1;
  Label3.Text = "当前页:" + CurPage.ToString();

  if (!pds.IsFirstPage)
  HyperLink2.NavigateUrl = Request.CurrentExecutionFilePath + "?Page=" + Convert.ToString(CurPage - 1);

  if (!pd