Home > DeveloperSection > Interviews > How do you connect (reference) to a SharePoint list, and how do you insert a new List Item?

Posted on    September-17-2011 2:31 AM

 SharePoint SharePoint 
 1 Answer(s)
  1933  View(s)
Rate this:

Chris Anderson
Chris Anderson

Total Post:197

Posted on    September-17-2011 12:00 AM


using(SPSite mySite = new SPSite("yourserver"))
using(SPWeb myWeb = mySite.OpenWeb())
SPList interviewList = myWeb.Lists["listtoinsert"];
               SPListItem newItem = interviewList.Items.Add();
               newItem["interview"] = "interview";newItem.Update();

Don't want to miss updates? Please click the below button!

Follow MindStick