如何结合ASP.NET TreeView控件中一个DataTable? [英] How to bind ASP.NET Treeview control to a datatable?
问题描述
我有这样的表结构:
- 类别ID
- 类别名称
- PARENTID
I have this table structure:
- CategoryID
- CategoryName
- ParentID
我想从该表数据加载到一个TreeView控件,以便能够编辑/删除这些记录。 那怎么办?
I want to load data from this table into a treeview control, to be able to edit/delete these records. How to do that?
推荐答案
有关详细信息,请参阅:<一href="http://stackoverflow.com/questions/372820/how-do-you-databind-to-a-system-windows-forms-treeview-control">How您数据绑定到TreeView控件?(问题是的WinForms,但仍然适用于ASP.NET)
For more details see: How do you databind to a TreeView control? (the question is WinForms, but still applies to ASP.NET)
长期和短期的是,你不能给数据绑定一个TreeView。的TreeView是分层的数据结构,因此不具有本地绑定机制。你必须推出自己的绑定来做到这一点。
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.
这篇关于如何结合ASP.NET TreeView控件中一个DataTable?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!