Click here to Skip to main content
15,887,434 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
am binding tree view from database table , now i added one more column description to my table , now i want to bind description when user click treeview node how to bind that

What I have tried:


<asp:TreeView ID="tvMenu" runat="server" OnSelectedNodeChanged="tvMenu_SelectedNodeChanged">



.cs
private void PopulateMenu()
{
List<tblemployee> allMenu = new List<tblemployee>();
using (TestDemoEntities dc = new TestDemoEntities())
{
allMenu = dc.tblEmployees.ToList();
}
// Call function here for bind treeview
CreateTreeView(allMenu, 0, null);
}
private void CreateTreeView(List<tblemployee> source, int parentID, TreeNode parentNode)
{
List<tblemployee> newSource = source.Where(a => a.ReportsTo.Equals(parentID)).ToList();
foreach (var i in newSource)
{
TreeNode newnode = new TreeNode(i.Name, i.EmpID.ToString());
if (parentNode == null)
{
tvMenu.Nodes.Add(newnode);
}
else
{
parentNode.ChildNodes.Add(newnode);
}
CreateTreeView(source, i.EmpID, newnode);
}
}

protected void tvMenu_SelectedNodeChanged(object sender, EventArgs e)
{

}
Posted
Updated 13-Jun-16 21:03pm
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900