I'm currently writing a custom web forms control with, among others, an embedded TreeView control. The content of this TreeView control is generated programmatically like this:
public void PopulateTreeView(TreeView treeView)
{
// Initialize with a single root node.
treeView.Nodes.Clear();
TreeNode currentNode = new TreeNode("root");
treeView.Nodes.Add(currentNode);
// Some logic with basically a depth first search through some data classes.
{
TreeNode node = new TreeNode(/* node label */);
currentNode.ChildNodes.Add(node);
if ( /* some condition */)
{
currentNode = node;
}
}
}
When rendering, everything looks fine, except that the ID for all HTML elements generated is ControlName1n0, which has the effect that clicking on the expand/collapse icons will only expand/collapse the root node.
Does anyone know what's the cause of this or how to fix this?