private void DeleteAllItemsUsingBatch()
{
using (SPSite site = new SPSite("http://mySharePointServer"))
{
SPWeb web = site.OpenWeb("/");
SPList list = web.Lists["Links"];
StringBuilder sb = new StringBuilder();
sb.Append("<batch>");
string batchCommand = "<method><setlist scope=\"Request\">" + list.ID + "</setlist><setvar name=\"ID\">{0}</setvar><setvar name=\"Cmd\">DELETE</setvar></method>";
foreach (SPListItem item in list.Items)
{
sb.Append(string.Format(batchCommand, item.ID.ToString()));
}
sb.Append("</batch>");
web.AllowUnsafeUpdates = true;
site.RootWeb.ProcessBatchData(sb.ToString());
web.AllowUnsafeUpdates = false;
web.Close();
}
}
can we do this using ClientOM
ReplyDeleteLet me see it Munnu once. I had not worked with Client Object Model with These kind of Multiple Deletion.
ReplyDeleteI dont know the option in Client Object Model, but we can do it in Javascript Web Services.
ReplyDelete