Wednesday, March 2, 2016

How to Insert New Item Into SharePoint List Programmatically

using (SPSite spSite = new SPSite(strSiteUrl, token))
{
spSite.AllowUnsafeUpdates = true;
using (SPWeb spWeb = spSite.OpenWeb())
{


SPList spList = spWeb.Lists["Enquiry"];

SPListItem spListItem = spList.Items.Add();

spListItem["Title"] = "Peak";
spListItem["Location"] = "India";


spWeb.AllowUnsafeUpdates = true;
 spListItem.Update();
}

}

No comments:

Post a Comment