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)
Available in Sandboxed Solutions: No
Available in SharePoint Online
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
list
Type: Microsoft.SharePoint.SPListThe list to view using the Web Part.
forCustomToolpane
Type: System.Booleantrue 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). |