web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Dynamics 365 Community / Blogs / Nishant Rana’s Weblog / Use TryGetList to check if ...

Use TryGetList to check if a list exist in SharePoint (SharePoint Object Model)

Nishant Rana Profile Picture Nishant Rana 11,325 Microsoft Employee

Hi,

We were getting the following error that “list doesn’t exist in the site” because the user was not having read permission on that list.

The code we were using was

SPList myList= spWeb.Lists[“mylist”];

A better approach would be

SPList myList = spWeb.Lists.TryGetList(“myList”);

If(myList != null )

// …

Bye ..


Filed under: SharePoint, SharePoint 2010, SharePoint 2013 Tagged: SharePoint, SharePoint 2010, SharePoint 2013

This was originally posted here.

Comments

*This post is locked for comments