0

I'm developing a visual webpart (TreeView). If I click on a node (folder), it gives me the credentials of the folder. Now, the values are all appearing in a label.

How can I return the users and groups not as string, but as a "SPUser-Hyperlink" like you can see in lists, when you create a coloumn and select the field "persons and groups".

1
String UserName= “UserNameGoesHere”; 

SPUser oUser= SPWeb.EnsureUser(UserName); 
treenode.SelectedNode.Nodes.Add(oUser.Name);

Where “UserNameGoesHere” you can change that to a varible as you loop through each string.

or from msdn

SPSite oSiteCollection = SPContext.Current.Site;
using (SPWeb oWebsite = oSiteCollection.AllWebs["Website_Name"])
{
    SPUser oUser = oWebsite.AllUsers["User_Name"];

    treenode.SelectedNode.Nodes.Add(oUser.Name);

}

http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.spuser.aspx

You would need to iterate through all the names by having in the using a while or forloop to go through the whole list!

hope this helps :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.