AddView Method
The AddView method of the Views service creates a view for the specified list.
Parameters
listName A string that contains the internal name of the list.
viewName A string that contains the GUID for the view, which determines the view to use for the default view attributes represented by the query, viewFields and rowLimit parameters. If this argument is not supplied, the default view is assumed.
viewFields A ViewFields element that specifies which fields to return in the query and that can be assigned to a System.Xml.XmlNode object, as in the following example:
<ViewFields><FieldRef Name="Title" /><FieldRef Name="ID" /></ViewFields>
query A Query element containing the query that determines which records are returned and in what order, and that can be assigned to a System.Xml.XmlNode object. For example, the following query returns list items where the ID is less than 3 and orders the items by title:
<Query>
<Where>
<Lt>
<FieldRef Name="ID" />
<Value Type="Counter">3</Value>
</Lt>
</Where>
<OrderBy>
<FieldRef Name="Title" />
</OrderBy>
</Query>
rowLimit A RowLimit element that specifies the number of items, or rows, to display on a page before paging begins, and that can be assigned to a System.Xml.XmlNode object. The fragment can include the Paged attribute to specify that the view return list items in pages. The following example sets a limit of 100 items per page:
<RowLimit Paged="True">100</RowLimit>
type A string that specifies whether the view will be an HTML view or a Datasheet view. Possible values include HTML and Grid.
makeViewDefault true to make the view the default view for the list.
Return Value
A Collaborative Application Markup Language (CAML) fragment in the following form that contains the view schema and that can be assigned to a System.Xml.XmlNode object:
<AddViewResult>
<View Name="{B5C3250A-1974-49E9-9F61-180F86704434}"
DefaultView="TRUE" Type="HTML" DisplayName="All Contacts"
Url="Lists/Contacts/AllItems.htm" BaseViewID="1" >
<RowLimit Paged="TRUE">100</RowLimit>
<ViewFields>
<FieldRef Name="LinkTitle" />
<FieldRef Name="FirstName" />
<FieldRef Name="Company" />
<FieldRef Name="WorkPhone" />
<FieldRef Name="HomePhone" />
<FieldRef Name="Email" />
</ViewFields>
<Query>
<OrderBy>
<FieldRef Name="Title" />
<FieldRef Name="FirstName" />
</OrderBy>
</Query>
<Aggregations></Aggregations>
<Formats></Formats>
</View>
</AddViewResult>
Example
The following code example creates a view for a specified list that returns items in which the value of a DateTime field is greater than a specified date and time.
This example requires that a using (C#) or Imports (Visual Basic .NET) directive be included for the System.Xml namespace.
Requirements
Platforms: Microsoft Windows Server 2003
Web Reference: http://Server_Name/[sites/][Site_Name/]_vti_bin/Views.asmx