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");
这句 大概什么意思 多谢指教
{
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");
这句 大概什么意思 多谢指教
http://msdn.microsoft.com/zh-cn/library/kxs7kbfe.aspx
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表中数据过多,这种分页没有实现真正的分页效果,应该要多少数据就取多少。
var result = list.Skip((this.AspNetPager1.CurrentPageIndex - 1) * (this.AspNetPager1.PageSize)).Take(this.AspNetPager1.PageSize).ToList(); //分页
把名为product的DataTable填充到ds(dataset)中,但是DataTable product中的内容并不是“select * from product”这条sql语句所生成的表的所有记录,而是这条sql语句所生成的表中从第PageSize * (PageCurrent - 1)条记录开始向后数PageSize条记录。