AspNetPager能用IQueryable<T>作为数据源吗
AspNetPager能用IQueryable<T>作为数据源吗?怎么用?各位大大请赐教,小弟初学wenform! --------------------编程问答-------------------- 分页和数据源没有直接关系的。--------------------编程问答-------------------- wenform是什么? --------------------编程问答-------------------- AspNetPager和数据没有直接关系,用什么数据源只和你怎么显示数据有关,AspNetPager只需要知道要分页的总记录数即可,请参考帮助和示例:http://www.webdiyer.com/controls/aspnetpager --------------------编程问答-------------------- 可以,只要你能返回总集的记录数,什么数据都能用AspNetPager --------------------编程问答-------------------- using System;
using System.Collections.Generic;
using System.Linq;
using System.Data;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Com.CMS.BLL;
using Com.CMS.Model;
using Webdiyer.WebControls.Mvc;
namespace CarRental.COM.CMS.em
{
public partial class ec : System.Web.UI.Page
{
protected Wuqi.Webdiyer.AspNetPager AspNetPager1;
protected System.Web.UI.WebControls.Label Label1;
private readonly BLLCarMes objBLLCarMes = new BLLCarMes();
protected void Page_Load(object sender, EventArgs e)
{
this.AspNetPager1.PageSize = 5;
if (!IsPostBack)
{
int count = objBLLCarMes.FindAllCarMesInfo().Count();
AspNetPager1.RecordCount = count;
this.BindData();
}
}
private void BindData()
{
IQueryable<CarMes> query = objBLLCarMes.FindAllCarMesInfo();
DataList1.DataSource = query; //在这里怎么传pagesize和CurrentPageIndex 等值
this.DataList1.DataBind();
this.Label1.Text = "当前第" + this.AspNetPager1.CurrentPageIndex + "页 总" + this.AspNetPager1.PageCount + "页";
}
private void AspNetPager1_PageChanged(object sender, System.EventArgs e)
{ //页索引改变方法
this.BindData();
}
}
}
这个代码怎么实现分页? --------------------编程问答--------------------
query.Skip((CurrentPageIndex-1)* pagesize).Take(pagesize)--------------------编程问答-------------------- 嗯!感谢sandy945大大!按您的办法已经解决
补充:.NET技术 , ASP.NET