首页 > 代码库 > Linq语句与aspnetpager结合分页
Linq语句与aspnetpager结合分页
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结合分页