I am using ASP.NET and C# to bind a tree view control in my application. The following code is used in WinForms, but it’s not working in WebForms. Can someone help to convert this to WebForms?
private TreeNode AddNode(TreeNode node, string key)
{
if (node.Nodes.ContainsKey(key))
{
return node.Nodes[key];
}
else
{
return node.Nodes.Add(key, key);
}
}
I want to implement the same logic. In WebForms we do not have method node.nodes, or node.nodes.Containskey().
In tree web control there is Value property, which can be used to store application data. But you have to manage it by yourself. Your code should look like this: