Prasad Bolla's SharePoint Blog

Click Here to go through the Interesting posts within my Blog.

Click Here to go through the new posts in my blog.

Monday, November 28, 2011

Delete a record based on ItemID using SharePoint Default WebService.

using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using PrasadBolla3;
using System.Xml;
public partial class Default9 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{

}
protected void btnDelete_Click(object sender, EventArgs e)
{
string strDeleteCommand = string.Empty;
strDeleteCommand = ""+ddlItemID.SelectedItem.Value+"";
PrasadBolla3.Lists objLogin = new PrasadBolla3.Lists();
objLogin.Credentials = new System.Net.NetworkCredential("true_indian9000", "prasad1234", "apptix");
objLogin.Url = "http://prasad.bolla3.sharepointsite.net/_vti_bin/Lists.asmx";
string strListName = "Login";
XmlDocument xmlDoc = new System.Xml.XmlDocument();

System.Xml.XmlElement elBatch = xmlDoc.CreateElement("Batch");

elBatch.SetAttribute("OnError", "Continue");

elBatch.SetAttribute("ListVersion", "1");

elBatch.InnerXml = strDeleteCommand;

XmlNode ndReturn = objLogin.UpdateListItems(strListName, elBatch);

string result = ndReturn.OuterXml.ToString();
Response.Write("Record Deleted");
}
}

No comments:

Post a Comment