Consider the following table. It has 3 filed with the following data. Now I want to show the data in TreeView Control in asp.net and c#
I will select all the data in a DataTable.
category_id category_name parents_id
1 Root NULL
2 Teacher 1
3 Student 1
4 TeacherA 2
5 TeacherB 2
6 TeacherC 2
7 StudentA 3
8 StudentB 3
9 StudentC 3
Here are some useful tips for you: for implementing tree view using asp.net and c#
NOte: I did not implement and did not use your datatable data here ….
TreeView control expects a heirarchical data structure, so we cant
bind the DataTable to menu directly.
Use data table Select where ParentID = ID
Please use a recursive method to create child items relevent to
current menu item ID
Here is an working example that you may use to transfer your
ralational data structure (TABLE) to hierarchical data
structure (TREE) using the relationship between ParentID and ID