Export (0) Print
Expand All
Expand Minimize

SPWeb.ViewStyles Property

Windows SharePoint Services 3

Gets the collection of view styles for the Web site.

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

public SPViewStyleCollection ViewStyles { get; }

Property Value

Type: Microsoft.SharePoint.SPViewStyleCollection
An SPViewStyleCollection object that represents the view styles.

The following code example uses the ViewStyles property to return the collection of view styles for a site and it applies a Newsletter style (15) to a view for a list in the specified site.

using (SPWeb oWebsite = SPContext.Current.Site.OpenWeb("Website_URL"))
    SPViewStyleCollection collViewStyles = oWebsite.ViewStyles;
    SPViewStyle oViewStyle = collViewStyles.StyleByID(15);
    SPList oList = oWebsite.Lists["List_Name"];
    SPView oView = oList.Views["View_Name"];

Certain objects implement the IDisposable interface, and you must avoid retaining these objects in memory after they are no longer needed. For information about good coding practices, see Best Practices: Using Disposable Windows SharePoint Services Objects.

Community Additions

© 2014 Microsoft