SPWeb.ViewStyles property
SharePoint 2013
Gets the collection of view styles for the website.
Assembly: Microsoft.SharePoint (in Microsoft.SharePoint.dll)
Property value
Type: Microsoft.SharePoint.SPViewStyleCollectionAn 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"]; oView.ApplyStyle(oView); oView.Update(); }
Note
|
|---|
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 Disposing Objects. |
Note