ASP.NET 4.5 GridView.AllowCustomCompaging属性如何简化此操作?
我有一个ASP.NET 4 GridView控件,它使用了这两篇文章中讨论的逻辑:ASP.NET 4.5 GridView.AllowCustomCompaging属性如何简化此操作?,asp.net,gridview,paging,.net-4.5,Asp.net,Gridview,Paging,.net 4.5,我有一个ASP.NET 4 GridView控件,它使用了这两篇文章中讨论的逻辑: ASP.NET 4.5GridView.AllowCustomPaging属性如何简化此操作 如果能链接到一篇关于如何使用它的文章,那将是非常受欢迎的。根据我最近的经验,它并不受欢迎 具体地说:在使用ASP.NET 4.5的系统实现高效的GridView自定义分页(仅从非常大的数据库表中检索所需的数据页)时,GridView.AllowCustomPaging属性没有进入其中 设置属性会导致使用模型绑定,
GridView.AllowCustomPaging
属性如何简化此操作
如果能链接到一篇关于如何使用它的文章,那将是非常受欢迎的。根据我最近的经验,它并不受欢迎 具体地说:在使用ASP.NET 4.5的系统实现高效的GridView自定义分页(仅从非常大的数据库表中检索所需的数据页)时,
GridView.AllowCustomPaging
属性没有进入其中
设置属性会导致使用模型绑定,这为我们提供了“ObjectDataSource样式”功能(如链接中所述),而不需要ObjectDataSource。在这种方法中,有两种选择:
(1)由GridView指定的方法。SelectMethod
返回一个IQueryable
,例如:
public IQueryable<MyClass> MySelectMethod1()
{
return myService.GetAll(someCriteria);
}
通过设置totalRowCount,我们现在为GridView提供了正确呈现其分页器所需的所有信息,同时只从数据库中检索了所需的数据页
我本来希望使用该属性(如上所述),但据我所知,totalRowCount
out参数排除了VirtualItemCount
属性
如果未实现(1)或(2),则GridView将引发异常:当DataBoundControl启用分页时,SelectMethod应返回IQueryable或应具有所有这些必需参数:int startRowIndex、int maximumRows、out int totalRowCount 因此,我们在ASP.NET 4.5中实现了GridView自定义分页。。。。但是使用
GridView.allowcustomaging
和GridView.VirtualItemCount
却看不到任何地方
public IList<MyClass> MySelectMethod2(int startRowIndex, int maximumRows, out int totalRowCount)
{
totalRowCount = myService.GetCount(someCriteria);
return myService.GetPage(someCriteria, startRowIndex, maximumRows);
}