首页 > Web开发 > 详细

Linq语句与aspnetpager结合分页

时间:2016-12-24 20:02:35      阅读:205      评论:0      收藏:0      [点我收藏+]

public void DataBindList()
        {
            List<EnDeContent> listCon = null;
            int pageSize = 10;
            int pageIndex =0;
            string key = txtKey.Text.Trim();
            AspNetPager.RecordCount = db.EnDeContent.ToList().Count();

            pageIndex = AspNetPager.CurrentPageIndex;

            if (string.IsNullOrEmpty(key))
            {
                listCon = db.EnDeContent.OrderBy(c => c.CodeDate).Skip(pageSize * (pageIndex - 1)).Take(pageSize).ToList();

            }
            else
            {
                listCon = db.EnDeContent.Where(c => c.CodeTitle.IndexOf(key) >= 0 || c.CodeContent.IndexOf(key) > 0).OrderBy(c => c.CodeDate).Skip(pageSize * (pageIndex - 1)).Take(pageSize).ToList();
            }

            Repeater1.DataSource = listCon;
            Repeater1.DataBind();
        }

      

Linq语句与aspnetpager结合分页

原文:http://www.cnblogs.com/jiaohuifeng/p/6217770.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!