Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All
Expand Minimize
Important This document may not represent best practices for current development, links to downloads and other resources may no longer be valid. Current recommended version can be found here.

SPWeb.GetList Method

Windows SharePoint Services 3

Returns the list that is associated with the specified server-relative URL.

Namespace:  Microsoft.SharePoint
Assembly:  Microsoft.SharePoint (in Microsoft.SharePoint.dll)

public SPList GetList(
	string strUrl


Type: System.String
A string that contains the server-relative URL for a list, for example, /sites/MySiteCollection/Lists/Announcements.

Return Value

Type: Microsoft.SharePoint.SPList
An SPList object that represents the list.

When you call the GetList method using the full URL for a list that does not exist, a FileNotFoundException is thrown and the value of the AllowUnsafeUpdates property changes to false.

Use the GetListFromWebPartPageUrl method to return the list that is associated with the first Web Part in a Web Part page.

Community Additions

© 2015 Microsoft