GibboK GibboK - 2 months ago 29
C# Question

Web Control TreeView select a Node programmatically

I use asp.net 4 and c#.
I have a TreeView and I would like select an existing node programmtically.

SelectNode() method is read only


http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.treeview.selectednode.aspx

so I do not know how to do it.
Please reply for a TreeView WEB CONTROL not for Win App.

My Code:

protected void uxTreeView_DataBound(object sender, EventArgs e)
{
TreeView myTreeView = (TreeView)uxManageSlotsDisplayer.FindControl("uxTreeView");
myTreeView.Nodes[2].Selected = true;
}

Answer Source

You can try setting the Selected property of a particular TreeNode.