SharePoint API Articles

Add a List Item Programmatically in SharePoint

The below code demonstrates how to use the SharePoint API to add a list items programmatically: string dashListRootStr= “http://sharepointSite/SubSite/Lists/MyList/”; using(SPSite site = new SPSite(dashListRootStr)) { using (SPWeb web = site.OpenWeb()) { SPList list = web.Lists["MySPList"]; SPListItem Item = list.Items.Add(); item["Title"] = txtCompanyName.Text; item["DateReceived"] = System.DateTime.Now; item["Description"] = txtDescription.Text; //Important: Comma and space required to add [...]

Read more

Delete a List Item Programmatically in SharePoint

The below code demonstrates how to use the SharePoint API to delete a list items programmatically: Delete an an tem without placing the item in the recycle bin: using (SPWeb web = siteCollection.AllWebs["thewebname"]) { SPList list = web.Lists["Document Library"]; SPListItem item = list.Items[guid]; item.Delete(); } Delete an an tem and place the item in the [...]

Read more