我正在使用WebDataTree来显示如下菜单:
+First Node
+first childNode
+Second Node
+Second childNode
+Third Node
+Third childNode
从上面的webdataTree菜单中,我该如何设置" + First Node"在页面加载时选择(默认选择)?
由于
答案 0 :(得分:0)
我通过以下代码实现了这个目标:
protected void WebDataTree1_PreRender(object sender, EventArgs e)
{
foreach (var item in WebDataTree1.AllNodes)
{
DataTreeNode treeNode = (DataTreeNode)item;
if (treeNode.Text.Equals("Chocolate")) {
treeNode.Selected = true;
WebDataTree1.SelectedNodes.Add(treeNode);
}
}
}