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();
posted @ 2009-09-01 00:58  悟〈--觉  阅读(405)  评论(0编辑  收藏  举报