View class
SharePoint 2013
Specifies a list view.
Namespace:
Microsoft.SharePoint.Client
Assemblies: Microsoft.SharePoint.Client.Silverlight (in Microsoft.SharePoint.Client.Silverlight.dll); Microsoft.SharePoint.Client.Phone (in Microsoft.SharePoint.Client.Phone.dll) Microsoft.SharePoint.Client (in Microsoft.SharePoint.Client.dll)
This code example orders the items on the Tasks list of the specified site in descending alphabetic order.
using System; using Microsoft.SharePoint.Client; namespace Microsoft.SDK.SharePointFoundation.Samples { class ViewExample { static void Main() { string siteUrl = "http://MyServer/sites/MySiteCollection"; ClientContext clientContext = new ClientContext(siteUrl); Web site = clientContext.Web; List targetList = site.Lists.GetByTitle("Tasks"); ViewCollection collView = targetList.Views; View targetView = collView.GetByTitle("All Tasks"); string strQuery = "<OrderBy><FieldRef Name=\'Title\' Ascending=\'False\' /></OrderBy>"; targetView.ViewQuery = strQuery; targetView.Update(); clientContext.ExecuteQuery(); Console.WriteLine("Tasks list ordered in descending alphabetic order."); } } }