HOW DO YOU CONNECT (REFERENCE) TO A SHAREPOINT LIST, AND HOW DO YOU INSERT A NEW LIST ITEM?

Chris Anderson

Total Post:197

Points:985
Posted by  Chris Anderson
 2419  View(s)
Ratings:
Rate this:
  1. Chris Anderson

    Post:197

    Points:985
    How do you connect (reference) to a SharePoint list, and how do you insert a new List Item?

    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();
              }
    }

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!