I am developing a web part (not a visual web part) that displays the site owners of a SharePoint site and their email addresses. Right now I am displaying the information in a listbox. It displays the site owners and emails like this:
Smith, John - [email protected]
Washington, Anna - [email protected]
This is the code I have:
public class SiteOwners : WebPart
{
string mySiteURL = "my SharePoint URL goes here";
ListBox mySPLists = new ListBox();
string listInfo = "";
protected override void CreateChildControls()
{
this.Controls.Add(mySPLists);
using (SPSite site = new SPSite(mySiteURL))
{
using (SPWeb web = site.RootWeb)
{
SPGroup ownerGroup = web.AssociatedOwnerGroup;
if (ownerGroup != null)
{
foreach (SPUser user in ownerGroup.Users)
{
listInfo = user.Name + " - " + user.Email;
mySPLists.Items.Add(listInfo);
}
}
//web.Dispose();
}
}
}
}
I would like to display the site owners' names and emails in 2 different columns so that it looks better. I want it to look like this:
Site Owner Email
Smith, John [email protected]
Washington, Anna [email protected]
Should I use a list view, data grid, table? Advice on how to use these items would be helpful.