Saturday, November 9, 2013

How to Add a Custom List Item Programatically in SharePoint

Below is code snippet:

using (SPSite site = new SPSite("site url"))
{
   using (SPWeb Web = site.OpenWeb())
   { 
     
      SPList list = Web.Lists["MyCustomList"];

      // Add new item in List
      SPListItem item = list.Items.Add();
      item["Title"] = “My Title”;
      item["Description"] = “My Description”;
      item.Update();
     
   }
}

No comments:

Post a Comment