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

How to check item exists before getItemByid

$
0
0

I am using in c#

item = list.GetItemById(40);

This throws error if the item with id 40 doe snto exists. I do not want to use try catch. Please advise how can I check if the item exists using GetItemByid before getting the item. Thanks.

Item does not exist. It may have been deleted by another user.
   at Microsoft.SharePoint.SPList.GetItemById(String strId, Int32 id, String strRootFolder, Boolean cacheRowsetAndId, String strViewFields, Boolean bDatesInUtc, Boolean bExpandQuery)


Viewing all articles
Browse latest Browse all 7589

Trending Articles



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