Quantcast
Channel: SharePoint 2013 - Development and Programming forum
Viewing all articles
Browse latest Browse all 7589

How to get the ID of the new inserted row in the SharePoint list by using web service

$
0
0

Hi, i am inserting new list items in share point list using web service by using the below code.

 ServiceReference.DataContext sc = new ServiceReference.DataContext(new Uri("http://servername:portnumber/_vti_bin/ListData.svc"));
 sc.Credentials = new System.Net.NetworkCredential(spusername, sppassword, spdomain);
 sc.AddToSampleList(new ServiceReference.SampleList
                                {
                                    Title= "Hello World"                                                              

                                });
  sc.SaveChanges();

Its working fine..

I need the ID of the new inserted row..

Is there anyway to get the ID of the newly inserted row just like in costume web part

SPList spList = spWeb.Lists["SampleList"];
SPListItem spListItem = spList.Items.Add();
spListItem["Title"] = "Hello world";
spListItem.Update();
int ID=spListItem.ID;//like this

Any help or suggestions please..

Thanks in advance... 


Viewing all articles
Browse latest Browse all 7589

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>