Repeater1如何实现分页功能
想从index.aspx页面中查询对应的发帖信息【发帖编号(ftid)】,然后在ftcx.aspx页面中,通过index.aspx页面中传来的(ftid)进行分页信息查询。
代码如下:
protected void Page_Load(object sender, EventArgs e)
{
ftck.Ftid = Convert.ToInt32(Request.QueryString["ftid"].ToString());
Repeater1.DataSource = ftck.SelectInfo1();
Repeater1.DataBind();
dlBind();
}
public void dlBind()
{
int curpage = Convert.ToInt32(this.labPage.Text);
PagedDataSource ps = new PagedDataSource();
SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["xiaochi"].ToString());
con.Open();
string mysql = "select * from ck2 where ftid=" +ftck.Ftid;
SqlCommand mycmd = new SqlCommand();
mycmd.Connection = con;
SqlDataAdapter dr = new SqlDataAdapter(mysql, con);
DataSet ds = new DataSet();
dr.Fill(ds, "ck2");
ps.DataSource = ds.Tables["ck2"].DefaultView;
ps.AllowPaging = true;
ps.PageSize = 2;
ps.CurrentPageIndex = curpage - 1;
this.lnkbtnUp.Enabled = true;
this.lnkbtnNext.Enabled = true;
this.lnkbtnBack.Enabled = true;
this.lnkbtnOne.Enabled = true;
if (curpage == 1)
{
this.lnkbtnOne.Enabled = false;
this.lnkbtnUp.Enabled = false;
}
if (curpage == ps.PageCount)
{
this.lnkbtnNext.Enabled = false;
this.lnkbtnBack.Enabled = false;
}
this.labBackPage.Text = Convert.ToString(ps.PageCount);
Repeater2.DataSource = ps;
Repeater2.DataBind();
}