How to add ListItem to List, "Person or Group" column

        SPWeb website = SPControl.GetContextWeb(Context);
        SPList oList = website.GetList("/Lists/Team%20Members");
       
        SPListItem item = oList.Items.Add();
        SPUser user;
        website.AllowUnsafeUpdates = true;
         user = website.SiteUsers["MOSSDEV1\\abc"];
        item["Member"] = user;
        item.Update();
        website.AllowUnsafeUpdates = false;

Comments

Popular posts from this blog

How to remove app from SharePoint 2013/2016

The model backing the context has changed since the database was created. Consider using Code First Migrations to update the database