SPWebPartManager.CreateWebPartFromList method (SPList, Boolean)

Creates a new Web Part that views a specified list and optionally forces selection of the ListViewWebPart class for the default view of a calendar list.

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

Syntax

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

returnValue = SPWebPartManager.CreateWebPartFromList(list, _
    forCustomToolpane)
public static WebPart CreateWebPartFromList(
    SPList list,
    bool forCustomToolpane
)

Parameters

  • forCustomToolpane
    Type: System.Boolean

    true to return an instance of the ListViewWebPart class for a calendar list; otherwise, false.

Return value

Type: Microsoft.SharePoint.WebPartPages.WebPart
An instance of the XsltListViewWebPart class if XSLT-rendered views are supported and the argument to the forCustomToolpane parameter is false; 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