Update people field in List SharePoint 2010

Sunday, October 7, 2012

using(SPSite mainsite=new SPSite("SPContext.Current.Site.Url"))
    using(SPWeb mainweb = site.OpenWeb())
                                    //Custom List Name
        SPList list = mainweb.Lists["MyList"];

        // Add new listItem
        SPListItem item = list .AddItem();

                                                 // UserID with domain
        SPUser user = web.AllUsers["SharePoint\\Usama"];

        item["Person"] = user;


share this post
Share to Facebook Share to Twitter Share to Google+ Share to Stumble Upon Share to Evernote Share to Blogger Share to Email Share to Yahoo Messenger More...