Sitecore 5.0 API

ChildList Class

Represents a list of subitems of an item.

For a list of all members of this type, see ChildList Members.

System.Object
   Sitecore.Collections.ChildList

[Visual Basic]
Public Class ChildList
    Implements ICollection, IEnumerable
[C#]
public class ChildList : ICollection, IEnumerable

Thread Safety

Public static (Shared in Visual Basic) members of this type are safe for multithreaded operations. Instance members are not guaranteed to be thread-safe.

Remarks

[Item Defined]]

An item can be retrieved by its ID, name or index in the collection.

The position of an item in the collection can be determined by using the IndexOf method.

To sort the collection like the Sitecore client, use the Sort method.

The collection can be converted to an array using the ToArray method.

Example

This example gets the names of the subitems that has the Document template.

public string GetDocumentNames() {
  string result = "";

  Item item = Sitecore.Context.Database.Items["/sitecore/content/Home"];

  foreach(Item child in item.Children) {
    if (child.Template.Name == "Document") {
      result += child.Name + ",";
    }
  }

  return result;
}

Requirements

Namespace: Sitecore.Collections

Assembly: Sitecore.Kernel (in Sitecore.Kernel.dll)

See Also

ChildList Members | Sitecore.Collections Namespace