How to bind ASP.NET Treeview control to a datatable?

Posted on

Problem :

I have this table structure:
– CategoryID
– CategoryName
– ParentID

I want to load data from this table into a treeview control, to be able to edit/delete these records.
How to do that?

Solution :

For more details see: How do you databind to a TreeView control? (the question is WinForms, but still applies to ASP.NET)

The long and short is that you can’t databind to a TreeView. TreeViews are hierarchical data structures and as such do not have a native binding mechanism. You’ll have to roll your own binding to do this.

Leave a Reply

Your email address will not be published. Required fields are marked *