Prasad Bolla's SharePoint Blog

Click Here to go through the Interesting posts within my Blog.

Click Here to go through the new posts in my blog.

Thursday, April 04, 2013

Insert User into People Picker Column who is not part of SiteCollection



SPSecurity.RunWithElevatedPrivileges(delegate()
                {
                    SPListItemCollection myColl = SPContext.Current.Web.Lists["Test People Editor"].Items;
                    SPListItem item = myColl.Add();
                    SPUser user = SPContext.Current.Web.EnsureUser(pplUserName.Accounts[0].ToString());
                    string strUser = user.ID.ToString();
                    SPContext.Current.Web.Update();
                    item["UserName"] = strUser;
                    item.Update();
                });

No comments:

Post a Comment