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)
Available in Sandboxed Solutions: No
Available in SharePoint Online

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