Checking exception before using GETITEMBYID()
Posted
by ps123
on Stack Overflow
See other posts from Stack Overflow
or by ps123
Published on 2010-03-13T22:13:32Z
Indexed on
2010/03/13
22:15 UTC
Read the original article
Hit count: 188
sharepoint
Hello,
I am getting item by getiembyid...but I want to check before using it that whether item exist or not...I don't want to use query as main purpose of using Getitembyid is performance.....any idea how to achieve this...
itemid = Response.QueryString["loc"];
SPList mylist = myweb.GetList(SPUrlUtility.CombineUrl(myweb.ServerRelativeUrl, "/Lists/Location"));
//now id itemid does not exist it throws exception...so i want to check before using following statement that itemid exist...I know i can check throw SPQuery but as i said above because of performance issue only i m using itemid....
SPListItem myitem = mylist.GetItemById(Convert.ToInt32(itemid));
Any idea how to achieve this?
© Stack Overflow or respective owner