2011-03-29 51 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