Export (0) Print
Expand All

Code to Get and Set Multi-valued Profile Properties

Commerce Server 2002

Use the following code to get and set multi-valued profile properties. The code should be used within a Commerce Server project. For more information about creating a Commerce Server project, see Creating a Commerce Project.

Profile userProfile;
ProfilePropertyGroup generalInfo;
ProfileContext profileContext = CommerceContext.Current.ProfileSystem;
Array favColorsIn = Array.CreateInstance( typeof(String), 3);
favColorsIn.SetValue("Red",0);
favColorsIn.SetValue("Blue",1);
favColorsIn.SetValue("Green",2);
.
.
.
// Create a user profile.
userProfile = profileContext.CreateProfile(LogonnameText.Text, "UserObject");

// Set multi-valued profile properties.
userProfile.PropertyGroups["GeneralInfo"]["fav_colors"].Value = favColorsIn;

// Persist user profile to underlying stores.
userProfile.Update();
.
.
.
// Get multi-valued profile properties.
Array favColorsOut = (Array) userProfile.PropertyGroups["GeneralInfo"]["fav_colors"].Value;

Copyright © 2005 Microsoft Corporation.
All rights reserved.
Was this page helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft