Binding to Database Data
You can’t bind a Menu
control directly to database data. Neither the SqlDataSource
nor ObjectDataSource
controls implement the IHierachicalDataSource
interface. Therefore, if you want to represent database data with the Menu
control, you need to perform some more work.
One option is to create your own SqlHiearachicalDataSource
control. You can do this either by deriving from the base HiearchicalDataSourceControl
class or implementing the IHiearchicalDataSource
interface. You take this approach in the final section of this chapter, when a custom SqlHierarchicalDataSource
control is built.
A second option is to build the menu items programmatically in the Menu
control. This is the approach followed here.
Imagine that you ...
Get ASP.NET 4 Unleashed now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.