Tuesday, May 29, 2012

How to use ProcessBatchData method in sharepoint

Here i want to deleting a list item from list.For this there is method PBD in sharepoint which is used to send the commands like save,delete. to server based on transaction.It can send multiple command at a time to server.I will give a simple example to delete the Xml  data of list using this method.For this i have passed the static values to xml data and delete command will be send to server
using(SPSite ss = new SPSite("site url"))
{
using(SPWeb sW = spSite.OpenWeb())
{
sbd.Append("");
sbd,Append("<ows:batch onerror="\&quot;Continue\&quot;">)
sbd.Append("<method>");
sbd.Append("<setlist>812e63a0b-65cab-50d8-b0c9-789d876b6020</setlist>");
sbd.Append("<setvar name="\&quot;ID\&quot;">" + 45 + "</setvar>");
sbd.Append("<setvar name="\&quot;Cmd\&quot;">Delete</setvar>");
sbd.Append("<setvar name="owsfileref">/mysite/files/documentss/testfile.txt</setvar>")
sbd.Append("<setvar name="owshiddenmodstatus">1</setvar>");
sbd.Append("</method>");
sbd.Append("</ows:batch>");
sw.ProcessBatchData(sbd.ToString());
}
}

No comments:

Bel