Share via


SPWebPartManager.CreateWebPartFromList method (SPList)

Creates a new Web Part that views a specified list.

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

Syntax

'Declaration
Public Shared Function CreateWebPartFromList ( _
    list As SPList _
) As WebPart
'Usage
Dim list As SPList
Dim returnValue As WebPart

returnValue = SPWebPartManager.CreateWebPartFromList(list)
public static WebPart CreateWebPartFromList(
    SPList list
)

Parameters

Return value

Type: Microsoft.SharePoint.WebPartPages.WebPart
An instance of the XsltListViewWebPart class if XSLT-rendered views are supported; otherwise, an instance of the ListViewWebPart class.

Exceptions

Exception Condition
ArgumentNullException

The argument to the list parameter cannot be a null reference (Nothing in Visual Basic).

See also

Reference

SPWebPartManager class

SPWebPartManager members

CreateWebPartFromList overload

Microsoft.SharePoint.WebPartPages namespace