Search This Blog

Friday, September 3, 2010

Checking whether SPList Exists

public static bool InspectForList(string listName)
{
var results = SPContext.Current.Web.Lists.Cast().Where(item => Equals(string.Compare(item.Title, listName, true), 0));
return results.Count()> 0;
}
-------------------------------------------------------------
public static bool ListExists(SPWeb web, string listName)
{
return web.Lists.Cast().Any(list => string.Equals(list.Title, listName));
}
------------------------------------------------------------------------------

No comments:

Post a Comment