Problema ListView annidati come Menu e sottomenu

martedì 19 febbraio 2013 - 13.58
Tag Elenco Tags  .NET 3.5  |  Visual Studio Express  |  VBScript

lukaone Profilo | Newbie

Salve a tutti!
Ho creato un menu con due listview annidati in questo modo:

<asp:ListView ID="LTWmenu" runat="server" DataSourceID="SQLmenu" DataKeyNames="id_categoria">
<LayoutTemplate>
<asp:PlaceHolder runat="server" ID="ItemPlaceHolder"></asp:PlaceHolder>
</LayoutTemplate>
<ItemTemplate>
<div style="float:left; width:180px; margin:1px 5px; padding:6px; background-color:#dbd9d9">
<asp:LinkButton ID="LNKcat" CommandName="collapsemenu" CommandArgument='<%# Eval("id_categoria") %>' runat="server"><%# Eval("nome_categoria") %></asp:LinkButton>
</div>
<asp:ListView ID="LTWsottomenu" runat="server" DataSourceID="SQLsottomenu" DataKeyNames="id_categoria">
<LayoutTemplate>
<asp:PlaceHolder runat="server" ID="ItemPlaceHolder"></asp:PlaceHolder>
</LayoutTemplate>
<ItemTemplate>

<div style="float:left; width:180px; margin:1px 5px; padding:6px; background-color:#f2f2f2; font-size:12px;">
<a href="<%# Eval("nome_categoria")%>"><%# Eval("id_categoria") %> - <%# Eval("nome_categoria") %></a>
</div>
</ItemTemplate>
</asp:ListView>
<asp:SqlDataSource ID="SQLsottomenu" runat="server"
ConnectionString="<%$ ConnectionStrings:connessione %>"
SelectCommand="SELECT * FROM tab_categorie WHERE parent_cat = @parent_cat ORDER BY nome_categoria">
<SelectParameters>
<asp:Parameter Name="parent_cat" DbType="Int32" />
</SelectParameters>
</asp:SqlDataSource>
</ItemTemplate>
</asp:ListView>

<asp:SqlDataSource ID="SQLmenu" runat="server"
ConnectionString="<%$ ConnectionStrings:connessione %>"
SelectCommand="SELECT * FROM tab_categorie WHERE parent_cat is NULL AND id_genere = @id_genere ORDER BY nome_categoria">
<SelectParameters>
<asp:Parameter Name="id_genere" DbType="Int32" />
</SelectParameters>
</asp:SqlDataSource>


e le voci del listview vengono generate da un itemcommand del primo listview così

Protected Sub LTWmenu_ItemCommand(sender As Object, e As ListViewCommandEventArgs) Handles LTWmenu.ItemCommand

If e.CommandName = "collapsemenu" Then

Dim cat As Integer
cat = e.CommandArgument().ToString

Dim sqlsottomenu As SqlDataSource
sqlsottomenu = DirectCast(e.Item.FindControl("SQLsottomenu"), SqlDataSource)

sqlsottomenu.SelectParameters("parent_cat").DefaultValue = cat
End If
End Sub

Funziona tutto correttamente ... l'unica cosa che vorrei è che quando clicco su una categoria, quella che ho aperto precedentemente si chiuda non mostrando i suoi risultati... ma ciò non accade!
Qualcuno ha qualche consiglio??
Grazie mille ...


Partecipa anche tu! Registrati!
Hai bisogno di aiuto ?
Perchè non ti registri subito?

Dopo esserti registrato potrai chiedere
aiuto sul nostro Forum oppure aiutare gli altri

Consulta le Stanze disponibili.

Registrati ora !
Copyright © dotNetHell.it 2002-2025
Running on Windows Server 2008 R2 Standard, SQL Server 2012 & ASP.NET 3.5