Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Jakob Jensen 23 posts 43 karma points
    Sep 10, 2010 @ 08:43
    Jakob Jensen
    0

    Pick member in role

    i need to get a list of users in a role. but the GetUsersInRole only return one row of data, Item containing a list of the users login-name. bur i also need the id of the user. i have found this but it is not returning any members.

    the GridView is just to see if there are members in the role

     protected void Page_Load(object sender, EventArgs e)
            {
                if (!Page.IsPostBack)
                {
    
    
                    MembershipUserCollection roleUsers = new MembershipUserCollection();
                    MembershipUserCollection users = Membership.GetAllUsers();
    
                    foreach (MembershipUser user in users)
                    {
                        if (Roles.IsUserInRole("AFF Instruktør"))
                        {
                            roleUsers.Add(user);
                        }
                    }
    
                    ddl_Ins1.DataSource = roleUsers;
                    ddl_Ins1.DataBind();
    
                    GridView1.DataSource = Roles.GetUsersInRole("AFF Instruktør"); 
                    GridView1.DataBind();
    
                }
            }
  • Richard Soeteman 4046 posts 12899 karma points MVP 2x
    Sep 10, 2010 @ 10:31
    Richard Soeteman
    0

    Are you using the MemberAlias to get the Members or are you using the name? You need to get the members by its alias  I also see that you are using Unicode chars, don't know if the database column supports that on the alias, so that could also be the case.

    Cheers,

    Richard

  • Jakob Jensen 23 posts 43 karma points
    Sep 10, 2010 @ 10:53
    Jakob Jensen
    0

    yes the Roles.GetUserInRole returns a list of the user alias,no Id only the alias. 

    there is no problem with the name of the role, the gridview shows a list of all members in the group

     

Please Sign in or register to post replies

Write your reply to:

Draft