2011-03-29 48 views

回答

0

这是如何设置TreeView以动态添加使用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 
    }); 
    } 
}; 
+0

非常感谢这个答案.. – Shilpa 2011-03-30 09:38:58