0

I am working on TreeView with checkbox(Parent and leaf) where I have to make some leaf nodes selected programatically.

Is it possible ?

I tried forach loop on treeview node but can make selected(checkbox) particular node.

I tried following solution Is it possible to get one of the child node get selected programatically

but I am getting error on SelectedNode that its read only

Code is as below :

<asp:TreeView ID="TreeView1" runat="server" ShowCheckBoxes="Leaf">
</asp:TreeView>

Now I am adding treeview node

for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
    {
    TreeView1.Nodes.Add(new TreeNode(ds.Tables[0].Rows[i]["ModuleName"].ToString(), ds.Tables[0].Rows[i]["Id"].ToString()));

   DataRow[] result = ds.Tables[1].Select("ModuleId = '"+ds.Tables[0].Rows[i]["Id"].ToString()+"'");
                    foreach (DataRow row in result)
                    {
                        TreeView1.Nodes[i].ChildNodes.Add(new TreeNode(row["PageCode"].ToString(), row["Id"].ToString()));
                    }
                }

and Now how do make particular leaf node selected ??

1 Answer 1

1

Please add you code so we can understand and answer proper.

If no TreeNode is currently selected, the SelectedNode property is null.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.