Reputation: 3790
I have build a sandbox webpart solution that runs through all groups of the current web and displays all members of the defined group. In my local SharePoint 2010 instance the webpart does exactly what it should but in the cloud i have no output. I have tried do display all available groups but the webpart also shows nothing, what is wrong with my code?
protected override void RenderContents(HtmlTextWriter writer)
{
base.RenderContents(writer);
foreach (string name in GetGroupMembers())
writer.Write(name);
}
public StringCollection GetGroupMembers()
{
StringCollection groupMemebers = new StringCollection();
SPGroupCollection groups = SPContext.Current.Web.Groups;
//for each item in the collection of groups
foreach (SPGroup group in groups)
//display all users from the defined group
if (group.ToString().Equals(DEFINED_GROUP))
foreach (SPUser user in group.Users)
groupMemebers.Add(user.Name);
return groupMemebers;
}
Upvotes: 2
Views: 827
Reputation: 3790
Solved it with:
SPGroupCollection groups = SPContext.Current.Site.RootWeb.Groups;
In my locals SharePoint I have only tested it in the root web.
Upvotes: 2