How to: Use the Nodes Iterator

This example shows how to collect the key values of all parent nodes displayed within the ASPxTreeList. The TreeListNodeIterator object is used to traverse through the nodes.

using System.Collections.Generic;
using DevExpress.Web.ASPxTreeList;

List<string> nodeKeys;
void ProcessNodes(TreeListNode startNode) {
    if (startNode == null) return;
    TreeListNodeIterator iterator = new TreeListNodeIterator(startNode);
    nodeKeys = new List<string>();
    while (iterator.Current != null) {
        GetParentNodeKey(iterator.Current);
        iterator.GetNext();
    }
}

private void GetParentNodeKey(TreeListNode node) {
    if (node != treeList.RootNode && node.HasChildren)
        nodeKeys.Add(node.Key);
}