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();
}
}
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.
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
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
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
is working on a reply...