Hi,
I want to set the selected node to the treeview on server side, I tried setting selected property to false but it's not working, and always root node is selected. How to set selectednode?
Thanks
I think that is because of no view state available in raise call back event . what i was trying to do was finding the node and set as selected node in the raise call back event where the was no view state and all the node text is empty.
I tried using the above code...for finding the child nodes with in the tree,, but WebDataTree1.AllNodes is giving correct node count but treeNode.Text having empty "" string for all the nodes. Is it the right way of finding for a node by text?
Hello kotapati,
I haven't shared any code snippet before because I thought that you were asking about confirmation.
Yes, you should iterate through All nodes of the WebDataTree and check the text / value of any of them.
If it matches you should simply set selected to true and add the item to the SelectedNodes collection.
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);
}
Let us know if you need further assistance regarding this
There is no code in your post. Can you please check that.
Hello kopati,
This is what you should do.
Let me know if you need further assistance.