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