I am using a treeview control and jus开发者_如何学Got want to add nodes dynamically.On selecting a node the results based on that node must be shown below.
Thanks in advance
This is how you set the TreeView to dynamically add the child nodes using Ajax.
var tree = new TreeView()
{
PopulateNodesFromClient = true,
EnableClientScript = true
};
tree.TreeNodePopulate += (s, e) =>
{
var childItems = CallTheDB(e.Node.Value); //Get the children for the parent node
foreach(var item in childItems)
{
e.Node.ChildNodes.Add(new TreeNode()
{
PopulateOnDemand = true,
Text = item.Text,
Value = item.Key,
SelectAction = TreeNodeSelectAction.Expand
});
}
};
精彩评论