Quantcast
Channel: ASP.NET - Code Snippets and Tutorials » membership
Viewing all articles
Browse latest Browse all 2

Filter Membership.GetAllUsers() in ASP.NET using Linq

$
0
0

Say that you want to retrieve only the Admin Users avoiding Regular Users:

UsersGrid.DataSource = 
      Membership.GetAllUsers().Cast<MembershipUser>()
     .Where(a => Roles.GetRolesForUser(a.UserName)[0] != "Regular User").ToList();

Or say you want to retrieve only the online users:

UsersGrid.DataSource =
     Membership.GetAllUsers().Cast<MembershipUser>()
    .Where(a => a.IsOnline)
    .OrderBy(a => a.LastLoginDate).ToList();

Viewing all articles
Browse latest Browse all 2

Latest Images

Trending Articles





Latest Images