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.StringA string that contains the name of the view.
strCollViewFields
Type: System.Collections.Specialized.StringCollectionA collection that contains the internal names of the view fields.
strQuery
Type: System.StringA Collaborative Application Markup Language (CAML) string that contains the Where clause for the query.
strJoins
Type: System.StringA CAML string that contains the joins for the query.
strProjectedFields
Type: System.StringA CAML string that contains the projected fields for the query.
iRowLimit
Type: System.UInt32The 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.Booleantrue to specify that the view supports displaying more items page by page; otherwise, false.
bMakeViewDefault
Type: System.Booleantrue to make the view the default view; otherwise, false.
type
Type: Microsoft.SharePoint.SPViewCollection.SPViewTypeAn enumeration value that specifies the type of view.
bPersonalView
Type: System.Booleantrue 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. |