Adding values to SharePoint People Editor using code

Posted: February 5, 2010 in Code, Object Model, People Picker

I was working with the People Editor Control and realized there are a couple weird things you need to do before you can read values into the control and save values into a list.  Here is a samples related to saving multiple/single user details into a people or groups column in a list.

SPFieldUserValueCollection UserCollection = new SPFieldUserValueCollection();
string[] UsersSeperated = pplEditor.CommaSeparatedAccounts.Split(‘,’);
if (UsersSeperated.Length > 0)
foreach (string UserSeperated in UsersSeperated)
SPUser User = web.SiteUsers[UserSeperated];
SPFieldUserValue UserName = new SPFieldUserValue(web, User.ID, User.LoginName);


This way we can store single or multiple user names in a People or Groups column from a people editor group.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s