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 (!pds.IsLastPage)
HyperLink3.NavigateUrl = Request.CurrentExecutionFilePath + "?Page=" + Convert.ToString(CurPage + 1);
Repeater1.DataSource = pds;
Repeater1.DataBind();
}
各位高手,小弟比较急,希望多加指点,最好详尽一点,这里小弟准备了高分感谢!
[解决办法]
用吴旗娃的分页控件吧,很方便的.
[解决办法]
使用aspnet.pager吴旗娃的分页控件,现在基本都懒的自己写分页显示啦