Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
330
Set selectedNode
posted

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

Parents
  • 19693
    posted

    Hello kotapati,

    You need to set the selected nodes during a  later  phase of the WebDataTree lifecycle.

    For example inside the PreRender event.

    Except setting the node to be selected you need to add it to the SelectedNodes collection.

        protected void WebDataTree1_PreRender(object sender, EventArgs e)

        {

            DataTreeNode node = (DataTreeNode)WebDataTree1.Nodes.FindNodeByText("Alfreds Futterkiste");

            node.Selected = true;

            WebDataTree1.SelectedNodes.Add(node);

     

            // another way

            WebDataTree1.Nodes[1].Selected = true;

            WebDataTree1.SelectedNodes.Add(WebDataTree1.Nodes[1]);

        }

     

    Let me know if you need further assistance regarding this.

Reply Children