Return to doc.sitecore.com

Valid for Sitecore 5.2, 5.1.1
  GetRootID
Prev Next

GetRootID returns the Sitecore ID of the data source’s top level item.

public override ID GetRootID(
  CallContext context
)

Sitecore represents all data as a hierarchy.  That is, all items have a parent and may have children.  One item, however, the root item, has no parent.  The root item is the top level item available in the data source. 

Whenever Sitecore requires the root item for a data source, it calls the GetRootID method.  If this method is not overridden, the default implementation will return the build-in value Sitecore.ItemsIDs.RootID.  If possible, do not override this method and associate the data source root item with the build-in value. 

The example shown below returns a hard-coded root ID.

public override ID GetRootID(CallContext context) {
  // This assumes that this class has an ID attribute called
  // MyRootID
  return MyRootID;
}


Prev Next