Partager via


Add(Microsoft.SharePoint.WebPartPages.ListViewWebPart) Method

The Add method of the SPWebPartCollection class adds the specified List View Web Part to the collection.

Parameters

listWebPart   A ListViewWebPart object that represents the new Web Part.

Return Value

A GUID that identifies the Web Part.

Example

The following example adds a List View Web Part to the collection of Web Parts that are displayed on the home page of the current site.

The ListName and ViewGuid properties both require a GUID represented as a string that uses all-uppercase characters and that is enclosed within curly braces ({ }).

This example requires using directives (Imports in Visual Basic) for the Microsoft.SharePoint, Microsoft.SharePoint.WebControls, and Microsoft.SharePoint.WebPartPages namespaces.

Requirements

Platforms: Microsoft Windows Server 2003

Security: Code Access Security