与PagedList及会员工作 [英] Working with PagedList and Membership

查看:141
本文介绍了与PagedList及会员工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在玩弄特洛伊古德的PagedList HTTP://pagedlist.$c$cplex.com / 。我想知道是否有人已经得到了它内置的asp.net成员一块工作?

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?

我有超过8000的用户,所以我需要能够直通页面用户列表。

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

用这样一行在我memberhsip控制器不工作。它不会编译。

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

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

鸭preciate在这方面的任何指导...

Appreciate any guidance in this area...

TIA

-MARK-
putrtek@gmail.com

-MARK- putrtek@gmail.com

推荐答案

Membership.GetAllUsers()返回类型MembershipUserCollection的一个实例。这类型不实现IEnumerable IQueryable的或。 ToPagedList是重载IEnumerable和IQueryable的扩展方法的集合。为了使用它,因此,你需要成员资格用户集合转换成这些类型之一。在IDE中,我承认有一个AsEnumerable方法。您可能需要使用System.Linq的用它来添加,虽然。因此,尝试:

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);

然而 GetAllUsers()已经重载做分页,所以你应该这样做,而不是:

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

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

这篇关于与PagedList及会员工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆