开发者

dynamically generating the nodes in treeview control and displaying the results on selecting the node in asp .net

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
     });
  }
};
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜