SPFieldUserValueCollection usernameCol = new SPFieldUserValueCollection();
SPsite osite = new SPSite(http://sharepoint2010/testing);
SPWeb oWeb = osite.OpenWeb();
SPList oList = oWeb.Lists["TestList"];
SPListItemCollection oListItemCol = oList.Items;
foreach (SPListItem items in oListItemCol)
{
SPUser user = items["PeoplePickerfield"];
if (user != null)
{
usernameCol.Add(new SPFieldUserValue(user.ParentWeb, user.ID, user.Name));
}
}
item["MultiplevalueallowedPeoplePickerField"] = usernameCol;
item.Update();
SPsite osite = new SPSite(http://sharepoint2010/testing);
SPWeb oWeb = osite.OpenWeb();
SPList oList = oWeb.Lists["TestList"];
SPListItemCollection oListItemCol = oList.Items;
foreach (SPListItem items in oListItemCol)
{
SPUser user = items["PeoplePickerfield"];
if (user != null)
{
usernameCol.Add(new SPFieldUserValue(user.ParentWeb, user.ID, user.Name));
}
}
item["MultiplevalueallowedPeoplePickerField"] = usernameCol;
item.Update();
No comments:
Post a Comment