Search code examples
asp.netfiltermembership

ASP.NET C# (3.5) Membership, How to get Approved Users only?


I need a list of "Approved" Users only, but don't know how to figure it out.

lstUsersNotInRole.DataSource = Membership.GetAllUsers(); // Get Approved Users Only!?!
lstUsersNotInRole.DataBind();

Any kind help would be highly appreciated.

Kardo


Solution

  • Instead of delving into the database and altering/creating stored procedures (and since you didn't specify which database you are using), you can do this by using Linq. Try this:

    Membership.GetAllUsers().Cast<MembershipUser>().Where(u => u.IsApproved == true).ToList();