Linq分页
int pagesize = 3;
int pageindex = 0;
if (pageindex < 1)
{
pageindex = 1;
}
pageindex = Convert.ToInt32(Request.QueryString["pageindex"]) ;
DataClassesDataContext db = new DataClassesDataContext();
var sql = from test in db.test
orderby test.id ascending
select test;
this.GridView1.DataSource = sql.Skip((pageindex - 1) * pagesize).Take(pagesize);
this.GridView1.DataBind();
int pageindex = 0;
if (pageindex < 1)
{
pageindex = 1;
}
pageindex = Convert.ToInt32(Request.QueryString["pageindex"]) ;
DataClassesDataContext db = new DataClassesDataContext();
var sql = from test in db.test
orderby test.id ascending
select test;
this.GridView1.DataSource = sql.Skip((pageindex - 1) * pagesize).Take(pagesize);
this.GridView1.DataBind();