I have a custom web part which have lot of fields that will be filed out by user and on submit is there a way that i can populate these values into a SharePoint list .I don't want to use info path as the web part also has lot of C# code in the background

 SPWeb app = SPContext.Current.Web;
            SPList ListName = app.Lists["Communities Directory"];
            SPListItem ListItem = ListName.Items.Add();
            string[] UsersSeperated = pickAdministrators.CommaSeparatedAccounts.Split(',');
            SPFieldUserValueCollection UserCollection = new SPFieldUserValueCollection();
            foreach (string UserSeperated in UsersSeperated)

                SPUser User = app.SiteUsers[UserSeperated];
                SPFieldUserValue UserName = new SPFieldUserValue(app, User.ID, User.LoginName);
            ListItem["Contact Person"] = UserCollection;

1 Answer 1


you can and would need to use the following:

Lists Web Sevice

Lists.UpdateListItems Method (Lists)

more can be found at:



In the codebehind for the webpart you could do:

SPWeb app = SPContext.Current.Web; 
SPList ListName = app.Lists["YourListName"]; 
SPListItem ListItem = ListName.Items.Add(); 
ListItem["field1Name"] = value; 
ListItem["field2Name"] = value; 

taken from here:


Hope it helps :)

  • Hi I am trying to update the share point list item with people picker field and i am using the following code but its always giving me specified user not found error .I pasted my code in the question .CAn you please help me with that
    – Anil
    Oct 25, 2012 at 22:54
  • hi sorry for the late reply been bussy! have you managed to solve the issue? have you debugged the code to see where exactly its breaking on?
    – Ali Jafer
    Dec 6, 2012 at 10:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.