C# PagedDataSource未获取数据源
我无法获取C# PagedDataSource未获取数据源,c#,datasource,icollection,entitycollection,C#,Datasource,Icollection,Entitycollection,我无法获取PagedDataSource以将EntityCollection对象的IEnumerated集合用作数据源 PagedDataSource接受集合作为数据源,但我不能使用基本属性,如CurrentPageIndex和IsLastPage等 我的应用程序中断,出现错误无法计算未实现ICollection的数据源的计数。 我试过了 ICollection listlocations=公司地点 但是没有成功 我能做什么 代码片段 protected void loadBuildin
PagedDataSource
以将EntityCollection
对象的IEnumerated集合用作数据源
PagedDataSource
接受集合作为数据源,但我不能使用基本属性,如CurrentPageIndex
和IsLastPage
等
我的应用程序中断,出现错误无法计算未实现ICollection的数据源的计数。
我试过了
ICollection listlocations=公司地点代码>
但是没有成功
我能做什么
代码片段
protected void loadBuildings()
{
PagedDataSource pds = new PagedDataSource();
pds.DataSource = Company.Locations;
pds.AllowPaging = true;
pds.PageSize = Convert.ToInt16(ddlPageSize.SelectedValue);
pds.CurrentPageIndex = CurrentPage;
lnkbtnNext.Enabled = !pds.IsLastPage;
lnkbtnPrevious.Enabled = !pds.IsFirstPage;
buildingsDataList.DataSource = pds;
buildingsDataList.DataBind();
}
我不得不使用选项allowcustomaging
并定义我自己的页面,因为EntityCollection
不支持ICollection
类
我添加了以下代码来定义我的页面/项目
pds.VirtualCount = Company.Locations.Count();
pds.PageSize = 3;
pds.AllowCustomPaging = true;
以及我的页面生成方法中的一些其他代码
for(int i=0;i<(pds.VirtualCount/pds.PageSize);i++