SiteMapNodeCollection Class
Assembly: System.Web (in system.web.dll)
public ref class SiteMapNodeCollection : IHierarchicalEnumerable, IList, ICollection, IEnumerable
public class SiteMapNodeCollection implements IHierarchicalEnumerable, IList, ICollection, IEnumerable
public class SiteMapNodeCollection implements IHierarchicalEnumerable, IList, ICollection, IEnumerable
Not applicable.
The SiteMapNodeCollection class provides a strongly typed collection for SiteMapNode objects. It stores SiteMapNode objects internally in a zero-based array.
You can modify a SiteMapNodeCollection collection when it is first created, and then use the following methods to add, copy, and remove SiteMapNode objects:
-
To add SiteMapNode objects, use the Add, AddRange, and Insert methods.
-
To copy SiteMapNode objects, use the CopyTo method.
-
To remove SiteMapNode objects, use the Remove method.
You can create a read-only SiteMapNodeCollection, which does not permit adding, copying, nor removing SiteMapNode objects, by using the static ReadOnly method. The SiteMapNodeCollection collections that are returned by the SiteMapNode.GetAllNodes and GetChildren methods are read-only, as is the SiteMapNodeCollection that is returned when the ChildNodes property is accessed on a SiteMapNode object that is returned from a provider. A NotSupportedException exception is thrown, if you attempt to modify a read-only SiteMapNodeCollection by setting the default indexer property or by using any of the following methods:
Use the IsReadOnly property to check the collection before calling any of the methods in the preceding list.
The following code example demonstrates how to create a SiteMapNodeCollection collection, and then add SiteMapNode objects to it using the AddRange method. The SiteMapNodeCollection is a subset of the current site map, showing only the first two hierarchical levels.
- AspNetHostingPermission for operating in a hosted environment. Demand value: LinkDemand; Permission value: Minimal.
- AspNetHostingPermission for operating in a hosted environment. Demand value: InheritanceDemand; Permission value: Minimal.