I had a requirement to build dynamic configurable menu and data will be populated from database rather than web.sitemap. And also the menu must support unlimited hierarchical levels. And also this piece of code must be reusable.
My idea was to bind the menu directly with dataset but unfortunately, dataset is not inherited and implemented IHierarchicalDataSource and it throws the exception. So, I tend to do traditional way of by adding menuItem in the loop. I know this is not a good idea and there must be someone who already implmented the neater way of binding directly by tweaking the dataset as the ASP.NET Menu has been released since 2 or 3 years ago.
Just a couple minutes spending on google and found this which is neater code and better design.
http://aspalliance.com/822
By using XMLDataSource and XSLT, this support unlimited hierarchical levels and only a few line of codes and clean.
Just have a look that above link if you are looking for building dynamic menu, it's worth to look it at.
Cheers
1 comment:
Hi,
Tha's fine.But how to build n-level menus if I don't know the hierarchy.
Currently in my case I need to go down to 5 levels.Can you tell me how can I build this dynamic menu from database
Post a Comment