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 
Ratings:
 1 Answer(s)
  2027  View(s)
Rate this:

Chris Anderson
Chris Anderson

Total Post:197

Points:985
Posted on    September-17-2011 12:00 AM

C#:

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