I am adding nodes to a TreeView control in Page Load as follows (code abbreviated):
foreach (WorkFlowTask workFlowTask in WorkFlowTasks)
{
aNode = new TreeNode(workFlowTask.TaskName, workFlowTask.OrderOfCompletion.ToString());
CreateNode(aNode); //This method adds nodes to their relative node path
//I have tried a couple things to cause a node to be expanded or collapsed here:
if (workFlowTask.IsCurrentTask)
{
aNode.Expand();
aNode.Expanded = true;
//and I also had some code to expand Parents:
// ExpandSelfAndAllParents(aNode);
//and I also had some code to Select a node (SelectedNodeStyle is set to yellow highlight:
//aNode.Select();
aNode.Selected = true;
}
else
{
aNode.Expanded = false;
aNode.Selected = false;
}
}
if (tvwWorkFlow.SelectedNode != null)
tvwWorkFlow.SelectedNode.Expand();
The result is the TreeView control renders all nodes expanded and the selected node is not highlighted in yellow (until I click on a node).
When I check tvwWorkFlow.SelectedNode after the Treeview control is built, it is null. The Selected property of every node in the TreeView, is null.
Help! Thanks...