using (SPSite oSite = new SPSite("http:\\serverName\site\TestProject"))
{
using (SPWeb oWeb = oSite.OpenWeb())
{
SPList oList = oWeb.Lists.TryGetList("TestList");
if (oList != null)
{
var listEnumeration = oList.Items.OfType<SPListItem>();
bool IsExist = listEnumeration.Any(p => p.ID == 1);
if (IsExist)
{
//List Item id exists in List
}
else
{
//List Item id doesn't exists in List
}
}
}
}
No comments:
Post a Comment