Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

In SharePoint 2010, I have created a custom user profile property named "MyCustomTools" in central admin as user Administrator.

Then I went to central admin and edit user profile and added vales in "MyCustomTools" as "Google;Facebook".

Now I want to retrieve values of custom properties like Google as link with url and Facebook as link with url. I am able to retrieve custom property name using below code:

new protected void Page_Load(object sender, EventArgs e)
        {
            using (SPSite site = new SPSite("servername"))
            {
                SPServiceContext context = SPServiceContext.GetContext(site);
                ProfileSubtypeManager psm = ProfileSubtypeManager.Get(context);
                ProfileSubtype ps = psm.GetProfileSubtype(ProfileSubtypeManager.GetDefaultProfileName(ProfileType.User));
                //Get the properties
                ProfileSubtypePropertyManager pspm = ps.Properties;
                foreach (ProfileSubtypeProperty profileSubtypeProperty in pspm.PropertiesWithSection)
                {
                    if (profileSubtypeProperty.Name == "MyCustomTools")
                    {
                        Label1.Text += profileSubtypeProperty.Name;
                    }
                }
            }
        }

but I need to retrieve values.

share|improve this question
add comment

1 Answer

Getting the value is pretty straight forward though this is best answered by looking at the code in this other question on this forum. That question is a little bit different from this one but provides a good example.

The .Value property will return a UserProfileValueCollection that you can iterate through to get the individual values.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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