我对创建网站菜单感到困惑。子菜单是完全动态的&由数据库制成。对于Menus,我使用了Listview Control,现在所有菜单都有子菜单(子菜单),它基于菜单。现在我不明白该怎么做。我想使用嵌套的ListView对此有好处,但我需要提示如何绑定嵌套的listview?
这是我的主要Listview
<asp:ListView ID="mainMenu" runat="server">
<ItemTemplate>
<li><asp:HyperLink ID="mainLinks" runat="server" NavigateUrl='<%# Eval("name", "~/{0}") %>' Text='<%# Eval("name") %>'></asp:HyperLink>
<ul class="super-child">
<asp:ListView ID="childMenu" runat="server">
<ItemTemplate>
<li><asp:HyperLink ID="cat3" runat="server" NavigateUrl='<%# Eval("category") & Eval("name", "/{0}") %>' Text='<%# Eval("name") %>'></asp:HyperLink></li>
</ItemTemplate>
</asp:ListView>
</ul>
</li>
</ItemTemplate>
</asp:ListView>
Private Sub bigMenu()
Dim constr As String = ConfigurationManager.ConnectionStrings("conio").ConnectionString
Using con As New MySqlConnection(constr)
Using cmd As New MySqlCommand()
cmd.CommandText = "SELECT * FROM mainMenu WHERE status = 'active' order by CAST(position as SIGNED INTEGER) asc"
cmd.Connection = con
Using sda As New MySqlDataAdapter(cmd)
Dim dt As New DataTable()
sda.Fill(dt)
mainMenu.DataSource = dt
mainMenu.DataBind()
End Using
End Using
End Using
End Sub
答案 0 :(得分:1)
您需要使用ListView ItemDataBound绑定嵌套的listview。 ItemDatBound将为您获取行值。请参阅我为您完成的以下代码
{{1}}