码迷,mamicode.com
首页 > Web开发 > 详细

Linq语句与aspnetpager结合分页

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

标签:data   pager   empty   stc   tab   lis   repeat   txt   derby   

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结合分页

标签:data   pager   empty   stc   tab   lis   repeat   txt   derby   

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!