Add(String, System.Collections.Specialized.StringCollection, String, UInt32, Boolean, Boolean, Microsoft.SharePoint.SPViewCollection.SPViewType, Boolean) Method
The Add method of the SPViewCollection class creates in the collection a view with the specified name, view fields, query string, row limit, Boolean values specifying whether the view displays items page by page and whether it is the default view, the view type, and a Boolean value specifying whether the view is personal or public.
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.
type A Microsoft.SharePoint.SPViewCollection.SPViewType value that specifies the view type.
bPersonalView true to create a personal view; false to create a public view.
Return Value
A Microsoft.SharePoint.SPView object that represents the view.
Example
The following code example creates a Grid view and displays items where a field value is less than 1,000.
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