Add(String, System.Collections.Specialized.StringCollection, String, UInt32, Boolean, Boolean) Method

The Add method of the SPViewCollection class creates a view in the collection with the specified name, view fields, query string, row limit, and Boolean values that specify whether the view displays items page by page and whether it is the default view.

Parameters

strViewName   A string that contains the name of the view.

strCollViewFields   A System.Collections.Specialized.StringCollection object that contains the internal names of the view fields.

strQuery   A string in Collaborative Application Markup Language (CAML) that contains the Where clause for the query.

iRowLimit   A 32-bit unsigned integer that specifies the maximum number of items to return in the view. Specifying a value greater than Int32.MaxValue (2,147,483,647 or hexadecimal 0x7FFFFFFF) throws an exception because the value is out of range.

bPaged  true to specify that the view supports displaying more items page by page; otherwise, false.

bMakeViewDefault  true to make the view the default view; otherwise, false.

Return Value

A Microsoft.SharePoint.SPView object that represents the new view.

Example

The following code example creates a view that returns items where the value of a field equals a specified text value.

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

Requirements

Platforms: Microsoft Windows Server 2003

Security: Code Access Security