SPViewCollection.Add method (String, StringCollection, String, String, String, UInt32, Boolean, Boolean, SPViewCollection.SPViewType, Boolean)

Creates a view in the collection with the specified name, view fields, query, joins, projected fields, row limit, view type, and Boolean values that specify whether the view displays items page by page, whether it is the default view, and whether the view is personal or public.

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

Syntax

'Declaration
Public Function Add ( _
    strViewName As String, _
    strCollViewFields As StringCollection, _
    strQuery As String, _
    strJoins As String, _
    strProjectedFields As String, _
    iRowLimit As UInteger, _
    bPaged As Boolean, _
    bMakeViewDefault As Boolean, _
    type As SPViewCollection.SPViewType, _
    bPersonalView As Boolean _
) As SPView
'Usage
Dim instance As SPViewCollection
Dim strViewName As String
Dim strCollViewFields As StringCollection
Dim strQuery As String
Dim strJoins As String
Dim strProjectedFields As String
Dim iRowLimit As UInteger
Dim bPaged As Boolean
Dim bMakeViewDefault As Boolean
Dim type As SPViewCollection.SPViewType
Dim bPersonalView As Boolean
Dim returnValue As SPView

returnValue = instance.Add(strViewName, _
    strCollViewFields, strQuery, strJoins, _
    strProjectedFields, iRowLimit, bPaged, _
    bMakeViewDefault, type, bPersonalView)
public SPView Add(
    string strViewName,
    StringCollection strCollViewFields,
    string strQuery,
    string strJoins,
    string strProjectedFields,
    uint iRowLimit,
    bool bPaged,
    bool bMakeViewDefault,
    SPViewCollection.SPViewType type,
    bool bPersonalView
)

Parameters

  • strViewName
    Type: System.String

    A string that contains the name of the view.

  • strJoins
    Type: System.String

    A CAML string that contains the joins for the query.

  • strProjectedFields
    Type: System.String

    A CAML string that contains the projected fields for the query.

  • iRowLimit
    Type: System.UInt32

    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
    Type: System.Boolean

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

  • bMakeViewDefault
    Type: System.Boolean

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

  • bPersonalView
    Type: System.Boolean

    true to create a personal view; false to create a public view.

Return value

Type: Microsoft.SharePoint.SPView
The new view.

Exceptions

Exception Condition
InvalidOperationException

The specified view type is not valid for the list template type.

See also

Reference

SPViewCollection class

SPViewCollection members

Add overload

Microsoft.SharePoint namespace