Tuesday, 30 August 2016

How to add values from people picker to List or Document Library in Sharepoint?

 

 <style  type="text/css">  
    .ms-inputuserfield{ font-size:8pt; font-family:Verdana,sans-serif; border:1px solid #a5a5a5;}
    div.ms-inputuserfield a{color:#000000;text-decoration: none;font-weight:normal;font-style:normal;}  
    div.ms-inputuserfield{padding-left:1px;padding-top:2px;}  
</style>



    string[] UsersSeperated = pplEditor.CommaSeparatedAccounts.Split(',');

    SPFieldUserValueCollection UserCollection = new SPFieldUserValueCollection();

    foreach (string UserSeperated in UsersSeperated)

       {

    mySite.EnsureUser(UserSeperated);

    SPUser User = mySite.SiteUsers[UserSeperated];

    SPFieldUserValue UserName = new SPFieldUserValue(mySite, User.ID, User.LoginName);

    UserCollection.Add(UserName);

   }

item["people"] = UserCollection;

No comments:

Post a Comment