asp.net Treeview issue (can't get child nodes to display)

NGamer

New Member
I have been working on this for a while, but cannot resolve the issue. I have searched S/O & Google, but no luck. Hoping someone on here can help resolve this. I am not able to display the child nodes in my TreeView control. The data is being retrieved from a database.
The root node appears fine, but there are not child nodes displayed. How can I get the child nodes to be displayed? My code is: \[code\]private void PopulateTreeNode(DataSet dsList){ var treeNode = new TreeNode(); foreach (DataRow dr in dsList.Tables[0].Rows) { if (dr["RecordTypeID"].ToString() == "1") { TreeNode NewNode = new TreeNode(dr["CustomerName"].ToString(), dr["customerID"].ToString()); treeCustomer.Nodes.Add(NewNode); } else if (dr["RecordTypeID"].ToString() == "2") { TreeNode pNode = new TreeNode(dr["CustomerName"].ToString(), dr["customerID"].ToString()); pNode.ChildNodes.Add(pNode); } else if (dr["RecordTypeID"].ToString() == "3") { TreeNode pNode = new TreeNode(dr["CustomerName"].ToString(), dr["customerID"].ToString()); pNode.ChildNodes.Add(pNode); } } treeCustomer.Nodes.Add(treeNode); treeCustomer.DataBind();}\[/code\]
 
Back
Top