c# - how to build html navigation bar dynamically using data from database -
i have data database self relation
parent_id name child_id 1 cities null 2 egypt 1 3 saudi 1 4 technology null 5 vb.net 4 6 c# 4
now want build html navigation bar using data
to following
<ul> <li><a href="#">cities</a> <ul> <li><a href="#">egypt</a></li> <li><a href="#">saudi</a></li> </ul> </li> <li><a href="#">technology</a> <ul> <li><a href="#">vb.net</a></li> <li><a href="#">c#</a></li> </ul> </li> </ul>
i don't know best way da xml node or using linqu ... whatever best way me please.
you can use asp:reapeater
control provide datasource , give html format inside it. easiest , efficient way.
explore more....
edited: you must mention
in mvc, can pass data inside viewbag
, viewdata
whatever , on view can use foreach iteration , inside generate required html
like
viewdate["data whatever"] = data
and on html
@foreach(var item in ....) { <a href='item.whatever value'> }
Comments
Post a Comment