how to bind TreeView to hierarchical data (Recursive Queries) ?
C#
1
Posts
1
Posters
0
Views
1
Watching
-
Hi i want to display hierarchical data in treeView, for example i have a recursive query which get employees and his/her manager in northwind database like this :
WITH cte1 (LastName, EmployeeID, Manager, ManagerID, Level)
AS
(
SELECT e1.lastName, e1.employeeID, e2.LastName, e1.ReportsTo, 0
FROM Employees e1 LEFT JOIN employees e2 on e1.ReportsTo = e2.EmployeeID
WHERE e1.ReportsTo IS NULLUNION ALL SELECT e1.lastName, e1.employeeID, c.LastName, e1.ReportsTo, Level + 1 FROM Employees e1 JOIN cte1 c ON e1.ReportsTo = c.EmployeeID
)
SELECT * FROM cte1now, i want to display this result set to treeview in hierarchical mode, but i don't know how to do this. can anybody provide source code ? thanks