views:

248

answers:

1

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- [email protected]

+2  A: 

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);
Craig Stuntz
Awesome! Thanks Craig. Just what I needed.
Mark Buckley
Just curiuos are you aware of a sample I can look at that shows how I can use the code you provided in a view to page through my 8000 users? I've gotten this to work (pagenation) with a 'normal' database table but I'm having some difficultly getting it to work with the membership system. TIA -MARK-
Mark Buckley
There is an example on the MSDN page I linked.
Craig Stuntz
Duh! Sorry I didn't realize that was a link... Thanks
Mark Buckley