SharePoint - Need help in sharepoint sharepoint list Item ID field

Asked By Rahul Khanna on 21-Sep-12 01:11 PM
Hi all,

Requesting to check the below code: 

<Method ID="1" Cmd="Update">
<Field Name="ID">4<Field>
<Field Name="Field_Name">Value</Field></Method>
<Method ID="2" Cmd="New"><Field Name="ID" >6</Field>
<Field Name="Field_Name">Value</Field></Method>
<Method ID="3" Cmd="Update">
<Field Name="ID" >8</Field>
<Field Name="Field_LookUp_Name">ID</Field>
</Method>
<Method ID="4" Cmd="Delete">
<Field Name="ID" >16</Field>
<Field Name="Field_Name">Value</Field>
</Method>

The above code I got from MSDN site, in the explanation Field Name="ID" is nothing but list Item ID. Based on what or how they are getting above field Name ID like: 4, 6, 8 16......Please somebody help me I am not understanding.

Rajat replied to Rahul Khanna on 26-Sep-12 10:36 AM
The code you have posted, is to update a list item

to update an list item you need to first know, which one to update ....Obviously you know that..but we need the ID of the item to update it

so, while reading i am sure you have a code like this
   foreach (XmlNode node in nodes)
          {
             StringBuilder methodBuilder = new StringBuilder();
             string itemID = node.Attributes["ows_ID"].InnerText;

 string methodFormat = "<Method ID=\"1\" Cmd=\"Update\">" +
               "<Field Name=\"ID\">{1}</Field>" +

and use that ID while building the update XML

Hope i could help . pls repost, if you need more help