Working with PagedList and Membership

元气小坏坏 提交于 2019-12-14 02:15:44

问题


I've been playing around with Troy Goode's PagedList http://pagedlist.codeplex.com/. I was wondering if anyone has gotten it to work with the built in asp.net Membership piece?

I have over 8000 users so I need to be able to page thru the User list.

using a line like this in my memberhsip controller doesn't work. It wont compile.

Membership.GetAllUsers().ToPagedList(currentPageIndex, defaultPageSize);

Appreciate any guidance in this area...

TIA

-MARK- putrtek@gmail.com


回答1:


Membership.GetAllUsers() returns an instance of type MembershipUserCollection. That type does not implement IEnumerable or IQueryable. ToPagedList is a collection of extension methods overloaded for IEnumerable and IQueryable. In order to use it, therefore, you need to transform the membership user collection into one of those types. In the IDE, I concede that there is an AsEnumerable method. You might have to add using System.Linq to use it, though. So try:

Membership.GetAllUsers().AsQueryable().ToPagedList(currentPageIndex, defaultPageSize);

However, GetAllUsers() is already overloaded to do paging, so you should do this instead:

Membership.GetAllUsers(currentPageIndex, defaultPageSize, out totalRecords);


来源:https://stackoverflow.com/questions/1214162/working-with-pagedlist-and-membership

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!