SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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;
share|improve this question

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 :)

share|improve this answer
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 '12 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 Sharepoint Dec 6 '12 at 10:02

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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