Wednesday, January 29, 2014

Delete SharePoint list all items using C# WPF Application

Hi Shimam,


You can make use of the Sharepoint client object model to perform any operations on the SharePoint list, in your case deleting the list item.


using SP client object model



using System;
using Microsoft.SharePoint.Client;
using SP = Microsoft.SharePoint.Client;

namespace Microsoft.SDK.SharePointServices.Samples
{
class DeleteListItem
{
static void Main()
{
string siteUrl = "http://MyServer/sites/MySiteCollection";

ClientContext clientContext = new ClientContext(siteUrl);
SP.List oList = clientContext.Web.Lists.GetByTitle("Announcements");
ListItem oListItem = oList.GetItemById(2);

oListItem.DeleteObject();

clientContext.ExecuteQuery();
}
}
}



The below link contains code to create, update or delete list item.


http://ift.tt/1fdzvNo




using Webservice


You also make use of SharePoint webservice to delete bulk items from Sharepoint list, you will send the below request to the webservice.



<Batch OnError="Continue" ListVersion="1"
ViewName="270C0508-A54F-4387-8AD0-49686D685EB2">
<Method ID="1" Cmd="Delete">
<Field Name='ID'>2</Field>
</Method>
</Batch>

In above case you will pass the id of the list item to be deleted.


Full code reference;


http://ift.tt/1jpGpVe




SRIRAM



No comments:

Post a Comment