Return to doc.sitecore.com

Valid for Sitecore 5.2, 5.1.1
  GetChildIDs
Prev Next

GetChildIDs returns an IDList with the IDs of all children of the given item.

public override IDList GetChildIDs(
  ItemDefinition item,
  CallContext context
);

Whenever Sitecore requires child items, it calls the GetChildIDs method, which returns the list of IDs corresponding to the given item’s immediate children.  The child Item IDs are returned, as opposed to the actual child objects, to allow the Abstract Data Layer to manage a cache of items.

The following example shows a GetChildIDs method which returns a hard coded list of IDs.

public override IDList GetChildIDs(ItemDefinition item, CallContext context) {
  // Create a list of IDs to return
  IDList children = new IDList();

  // The following two lines assume that this class has two
  // ID attributes called MyFirstChildID and MySecondChildID
  children.Add(MyFirstChildID);
  children.Add(MySecondChildID);

  // Always return these two children.  A more useful
  // method would build a list dynamically.
  return children;
}


Prev Next