Repeater 分页

来源:百度知道 编辑:UC知道 时间:2024/06/25 09:39:53
Repeater 分页

我做过这样的:public partial class Repeater : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
this.Label2.Text ="1";
databindrepeater();
}
}
private void databindrepeater()
{
int curPage =Convert.ToInt32(this.Label2.Text);
SqlConnection con = DB.createCon();
SqlDataAdapter sda = new SqlDataAdapter();
sda.SelectCommand = new SqlCommand("select * from person", con);
DataSet ds = new DataSet();
sda.Fill(ds, "person");
PagedDataSource pds = new PagedDataSource();
pds.DataSource = ds.Tables["person"].DefaultView ;
pds.AllowPaging = true;
pds.CurrentPageIndex=curPage - 1;
pds.PageSize = 2;
if (curPage == 1)
{
this.btnFont.Enabled = false;
}
else
{
this.btnFont.Enabled = true;
}
if (curPage == pds.PageCount)
{
this.b