EF分页

        protected virtual void InitGrid()
        {
            var q = _IContracts.Entities;

            q = Search(q);

            GridList.RecordCount = q.Count();

            if (GridList.PageIndex >= GridList.PageCount && GridList.PageCount >= 1)
            {
                GridList.PageIndex = GridList.PageCount - 1;
            }
            q = q.SortBy(OrderField);

            GridList.DataSource = q.Skip(GridList.PageIndex * GridList.PageSize).Take(GridList.PageSize).ToList();
            GridList.DataBind();
        }

 

posted @ 2017-04-04 12:46  shiningrise  阅读(147)  评论(0编辑  收藏  举报
// 侧边栏目录 // https://blog-static.cnblogs.com/files/douzujun/marvin.nav.my1502.css