protected void Page_Load(object sender, EventArgs e)
    {
        AspNetPager1.RecordCount = db.newsmore();        Repeater1.DataSource = db.newsmoreBind(AspNetPager1.PageSize, AspNetPager1.CurrentPageIndex);
        Repeater1.DataBind();
        
    }
    protected void AspNetPager1_PageChanged(object sender, EventArgs e)
    {
        Repeater1.DataSource = db.newsmoreBind(AspNetPager1.PageSize, AspNetPager1.CurrentPageIndex);
       Repeater1.DataBind();
    } public static int productmore()
    {
        OleDbConnection conn = new OleDbConnection(db.connstring);
        conn.Open();
        OleDbCommand cmd = new OleDbCommand("select count(*) from product", conn);
        int i = (int)cmd.ExecuteScalar();
        conn.Close();
        return i;
    }
    public static DataSet productmoreBind(int PageSize, int PageCurrent)
    {
        OleDbConnection conn = new OleDbConnection(db.connstring);
        OleDbDataAdapter da = new OleDbDataAdapter("select * from product", conn);
        DataSet ds = new DataSet();
        da.Fill(ds, PageSize * (PageCurrent - 1), PageSize, "product");
        return ds;
    }
里面的productmoreBind(int PageSize, int PageCurrent) da.Fill(ds, PageSize * (PageCurrent - 1), PageSize, "product");
这句 大概什么意思  多谢指教

解决方案 »

  1.   

    OleDbDataAdapter 实现分页
    http://msdn.microsoft.com/zh-cn/library/kxs7kbfe.aspx
      

  2.   

    分页pageSize每页行数PageCurrent当前页码
      

  3.   

    da.Fill(ds, PageSize * (PageCurrent - 1), PageSize, "product");ds是product表中数据库中的所有数据
    select top 10 * from product where id not in (select Id from product where id>20)PageSize * (PageCurrent - 1)相当于id>20,PageSize相当于top 10da.Fill(ds, PageSize * (PageCurrent - 1), PageSize, "product");中的product是ds的名字ds.TableName="product";如果product表中数据过多,这种分页没有实现真正的分页效果,应该要多少数据就取多少。
      

  4.   

    使用这个需要你返回一个List<表对象>集合//其中list就是你返回的集合,将result绑定到你的控件中去
    var result = list.Skip((this.AspNetPager1.CurrentPageIndex - 1) * (this.AspNetPager1.PageSize)).Take(this.AspNetPager1.PageSize).ToList();  //分页
      

  5.   

    da.Fill(ds, PageSize * (PageCurrent - 1), PageSize, "product");
    把名为product的DataTable填充到ds(dataset)中,但是DataTable product中的内容并不是“select * from product”这条sql语句所生成的表的所有记录,而是这条sql语句所生成的表中从第PageSize * (PageCurrent - 1)条记录开始向后数PageSize条记录。