Logo 
Search:

Sharepoint FAQ

Submit Interview FAQ
Home » Interview FAQ » SharepointRSS Feeds

How do you connect (reference) to a Sharepoint list, and how do you insert a new List Item?

  Shared By: Tarang Nayak    Date: Mar 12    Category: Sharepoint    Views: 1538

Answer:

Select For Unformatted Code
C#:
1. using(SPSite mySite = new SPSite("yourserver"))
2. {
3. using(SPWeb myWeb = mySite.OpenWeb())
4. {
5. SPList interviewList = myWeb.Lists["listtoinsert"];
6. SPListItem newItem = interviewList.Items.Add();
7.
8. newItem["interview"] = "interview";
9. newItem.Update();
10. }
11. }

Share: 
 



Your Comment
  • Comment should be atleast 30 Characters.
  • Please put code inside [Code] your code [/Code].


Tagged: