views:

29

answers:

1

I am building a project in asp.net 4.0. My navigation will be database driven where i return a datatable from the db containing all the pages of my site, some will be top level while others will be children and sometimes children of children n-times.

Im thinking of going down the nested repeater route and databinding from code behind, dynamically generating repeaters for children, but have read that this is not a best practice and should consider the listview control.

Im wanting to build a list of links using an unordered list.

I cannot find a solid example and was hoping for some pointers/ideas.

Thanks

Doo

+1  A: 

My suggestion would be to use the sitemap provider and make a custom one. I did this at work for the framework we built and it sounds pretty similar to what you are trying to do. It might require a little effort up front but the nice thing is that once your done the rest of the built in navigation features just work.

Here is a link to an article from MSDN magazine on how to build your own SQL Site Map Provider.

http://msdn.microsoft.com/en-us/magazine/cc163657.aspx

Patricker
I have used this in the past, is there an alternative approch though?
Dooie
I'm sure there are a dozen different approaches that could be taken. While you could use a ListView for page navigation... it doesn't remotely make sense. ListView is a pretty powerfull control normally used for View/Edit/Insert/Delete of data. I'm fairly sure you are just wanting to allow viewing of your navigation and not normally allow manipulation except through some admin page. If you don't want to make your data work with the built in ASP.Net menu controls then I would probalby use a Repeater since that provides the most flexibility and you can nest them if you want.
Patricker