How to change the System.Web.UI.Webcontrols (Treenode) dynamic "Id" in c#

Asked

Viewed 44 times

1

I’m new to the subject, and I’m creating a dynamic structure of treenodes, in this structure the id of the nodes, is automatically implementing, but I’d like to define the id of the nodes, so it doesn’t have the id property, in this nodes. If anyone can help me I thank you. (Note: The Node are being inserted in an "Asp:Treeview"). follows part of the code.

using System.Web.UI.WebControls;
protected void treenodes()
{
 TreeNode tree = new Treenode();
 tree.text = "My TreeNode";
 Tree.value = 1;
 tree.SelctAction = SelectAction = TreeNodeSelectAction.Expand;
 //aqui são os childNodes
 Treenode subTree = new TreeNode();
 subtree.text = "My TreeNode";
 subTree.value = 1.1;
 tree.ChildNodes.Add(subTree);
 TreeView.Nodes.Add(tree);
}
  • 1

    There is no property Id, but there is the Name.

  • @Joãomartins believe that the property Name, and only for treeNodes for system.Windows.Form, in this case I am in a system.web.UI.Controls structure, and does not present either of these properties.

  • 1

    You’re right, I had an idea it existed. But you can use the property Value, which, according to the help, serves to store information related to the node and is not visible in the UI. I saw that you are already using, so you can Id knotted.

  • Yes, it has the property Value, but for some reason that at the moment it is unknown it is being changed by threenode, this one presenting empty value;

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.