You'll need an extra for each loop to iterate through each member's groups. This should do the trick:
@{
int total;
var members = ApplicationContext.Services.MemberService.GetAll(1, 0, out total);
foreach (var member in members)
{
var groups = Roles.GetRolesForUser(member.Username);
if (!groups.Any())
{
continue;
}
foreach (var group in groups)
{
@group
}
}
}
List member properties and group names
Hi,
I have a member page, where I show the members with their properties like name, birthday and so.
Now I would like to show which groups the different members are part of. How do I do that? Is there a special property i can retrieve?
Thanks for your help! :-)
/Daniel
u7
Hi Daniel,
For each member displayed on the page, you should be able to use the following method to retrieve a list of groups the member is a part of:
Hope that helps.
Thanks, Dan.
Thanks Dan!
I hope you will help me a bit more.
I have this code, but I am doing it wrong.
Thank you for your help! :-)
/Daniel
Hi Daniel,
You'll need an extra for each loop to iterate through each member's groups. This should do the trick:
Hope that helps.
Thanks, Dan.
Thank you very much for helping me!
I get this error unfortunatly: "The name 'ApplicationContext' does not exist in the current context"
/Daniel
Hmmm strange. Maybe try using the following instead. Although I'd suggest only using the new Services if possible.
Thanks, Dan.
Thank you!
Can it have anything to do with me using macroscripts and not partial views?
That did not work either.
/Daniel
is working on a reply...