Using this code,just pass necessary parameter to run this code.
For Insert Item Query:
string caml="<Method ID=\"1\" Cmd=\"New\">" + "<Field Name=\"ID\">New</Field>" + "<Field Name=\"Title\">" + TextBox1.Text.ToString() + "</Field>" + "</Method>";
For Update Item Query:string caml="<Method ID=\"1\" Cmd=\"New\">" + "<Field Name=\"ID\">1</Field>" + "<Field Name=\"Title\">" + TextBox1.Text.ToString() + "</Field> + "</Method>";
For Delete Item Query :
string caml="<Method ID=\"1\" Cmd=\"New\">" + "<Field Name=\"ID\">1</Field></Method>";
TP.WebService.ListOperation listItemAdd = new TP.WebService.ListOperation();
listItemAdd.
public bool InsertUpdateDeleteListItem(string UserName, string Password, string Domain, string SiteURL,string CAML,string ListName)
{
try
{
ListData.Lists list = new ListData.Lists();
list.Url = SiteURL +"/_vti_bin/lists.asmx";
list.Credentials = new System.Net.NetworkCredential(UserName,Password,Domain);
System.Xml.XmlDocument xmlDoc;
System.Xml.XmlElement elBatch;
System.Xml.XmlNode ndReturn;
xmlDoc = new System.Xml.XmlDocument();
elBatch = xmlDoc.CreateElement("Batch");
elBatch = xmlDoc.CreateElement("Batch");
elBatch.SetAttribute("OnError", "Continue");
string strBatch = CAML;
elBatch.InnerXml = strBatch;
ndReturn = list.UpdateListItems(ListName, elBatch);
return true;
}
catch (Exception)
{
return false;
}
return true;
}