The PeopleEditor control is a wonderful control to help you easily select one or more users from the users known in the directory service of the server. The PeopleEditor control performs queries against the Active Directory.To select more then one user we need to set the property MultiSelect to true.
Here is the code snippet that demonstrates how we can get and set the value of PeopleEditor control with Multiselect property set to true .
//get the collection of users from people editor
SPFieldUserValueCollection srvcRepCol = new SPFieldUserValueCollection();
int index = 0;
for (index = 0; index <= this.peopleEdControl.ResolvedEntities.Count - 1; ++index)
PickerEntity objEntity = (PickerEntity)this.peopleEdControl.ResolvedEntities[index];
srvcRepCol.Add(new SPFieldUserValue(srvcWeb, Convert.ToInt32(objEntity.EntityData["SPUserID"]), objEntity.Key));
//Assign the users to list item column
item["Customers"] = srvcRepCol;
//Set the value of users to people editor
if (item["Customers"] != null))
string users = string.Empty;
//To get the value from sharepoint list item and storing it in a SPFieldUserValueCollection.
SPFieldUserValueCollection userCol = new SPFieldUserValueCollection(web, item["Customers"].ToString());
foreach (SPFieldUserValue usrItm in userCol)
users += usrItm.User.ToString() + ",";
this.peopleEdControl.CommaSeparatedAccounts = users.Remove(users.LastIndexOf(","), 1);