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

I defined a multi value string for user profile properties in the backend of my SharePoint 2010. I'm reading the content from the created property like this: propertyValue = profile[propname].Value.ToString(); unfortunately i'm getting only the first stored value of the multi value field.

profile in the code is of type UserProfile and has GetUserProfile(accountName) from the UserProfileManager in it

Any Ideas how to get all multi values?

share|improve this question
add comment

1 Answer 1

up vote 1 down vote accepted

The profile property is actually a UserProfileValueCollection.

e.g.

UserProfileValueCollection propertyCollection = profile[propname];
foreach(var prop in propertyCollection)
{
    Console.WriteLine(prop.ToString());
}
share|improve this answer
    
Are you sure that UserProfilePropertyCollection exists? Doesn't work for me and i can't find anything on the internet about it.. –  Peter Oct 21 '11 at 16:03
    
On the top of my head it's UserProfileValueCollection in stead of UserProfileProperyCollection –  Anita Boerboom Oct 21 '11 at 18:55
    
Sorry, I was working off 2007... If you use 'var' it should work ok... –  SHug Oct 21 '11 at 22:12
    
Just tested it - my code looks like this: ` if (profile[propname].Value != null) { UserProfileValueCollection propertyCollection = profile[propname]; propertyValue = propertyCollection.ToString(); } else { propertyValue = String.Empty; } sectionProperties.Add(propDisplayName, propertyValue);` still there ist just one Value inside of the propertyCollection –  Peter Oct 27 '11 at 13:30
    
Edited per suggestion –  SPDoctor Dec 29 '12 at 11:15
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.