Codebanking.com Bank your code here...
HOME REGISTER TECHNICAL Q&A GENERAL Q&A SUBMIT CODE SNIPPET LOGIN
 



Add item in people or group field using sharepoint object model

SPFieldUserValueCollection spFieldUserValueCollection = new SPFieldUserValueCollection();

strUser=”domain\loginname”;
SPSecurity.RunWithElevatedPrivileges(delegate()
    {
using (SPSite spsite = new SPSite(SPContext.Current.Site.Url))
    {
     SPWeb spweb = spsite.OpenWeb();
     spuser = spweb.EnsureUser(strUser);
     spFieldUserValueCollection.Add(new SPFieldUserValue(web, spuser.ID, spuser.LoginName));
     listitems[values[0]] = spFieldUserValueCollection;
     spweb.Dispose();
    }                                

 });
listitems.update();



Comments Posted:
No Comments Posted
Please login for leave your comments
 
 2010 codebanking.com      contactus@codebanking.com