问题描述
我正在使用菜单控件,并且想根据我的sql条件隐藏菜单.
最初,我在设计模式下加载所有菜单.
在页面加载时,根据我的sql条件,我从列表中删除了菜单.
我想,当我删除主菜单中的一个菜单时,整个主菜单和主子菜单都应该消失.
当我删除交易中的一个菜单时,整个交易和子交易菜单都应该消失.
怎么做..
看到我的代码
------------
ASPX页面
----------
Hi,
I am using menu control and i want to hide the menu''s based on my sql condition.
Initially i am loading all the menu''s in the design mode.
while page load and based on my sql condition i am removing the menu''s from the list.
I want, when i remove one menu in master then the entire master and master child menu should be disappear.
When i remove one meni in transaction then entire transaction and child transaction menu should be disappear.
how to do this..
see my code
------------
ASPX Page
----------
<div id="menu" class="nav">
<asp:Menu ID="NavigationMenu" runat="server" Orientation="Horizontal" RenderingMode="List">
<Items>
<asp:MenuItem NavigateUrl="~/Home.aspx" Text="Home" Value="Home" />
<asp:MenuItem Text="Master" Value="Master">
<asp:MenuItem Text="Master_Child1" Value="Master_Child1"></asp:MenuItem>
<asp:MenuItem Text="Master_Child2" Value="Master_Child2"></asp:MenuItem>
<asp:MenuItem Text="Master_Child3" Value="Master_Child3"></asp:MenuItem>
</asp:MenuItem>
<asp:MenuItem Text="Transaction" Value="Tran">
<asp:MenuItem Text="Tran_Child1" Value="Tran_Child1"></asp:MenuItem>
<asp:MenuItem Text="Tran_Child2" Value="Tran_Child2"></asp:MenuItem>
</asp:MenuItem>
<asp:MenuItem Text="Reports" Value="Report">
<asp:MenuItem Text="Reports" Value="Reports"></asp:MenuItem>
<asp:MenuItem Text="Report_Child1" Value="Report_Child1"></asp:MenuItem>
</asp:MenuItem>
<asp:MenuItem NavigateUrl="~/Others.aspx" Text="Others" Value="Others" />
</Items>
</asp:Menu>
</div>
ASPX.VB代码
-------------
--------------
ASPX.VB Code
-------------
--------------
NavigationMenu.Items.Clear()
Conn.Open()
StrQry = ""
StrQry = " Select isnull(Home,'') as Admin,isnull(Master_Child1,'') as Master_Child1,isnull(Master_Child2,'') as Master_Child2,"
StrQry &= " isnull(Tran_Child1,'') as Tran_Child1,isnull(Tran_Child2,'') as Tran_Child2,"
StrQry &= " isnull(Report_Child1,'') as Report_Child1,isnull(Report_Child2,'') as Report_Child2,"
StrQry &= " isnull(Others,'') as Others"
Cmd.Connection = Conn
Cmd.CommandText = StrQry
Rdr = Cmd.ExecuteReader
If Rdr.HasRows Then
While Rdr.Read
If Rdr("Home") = "N" Then
Dim mnuItems As New MenuItem()
NavigationMenu.Items.Remove(mnuItems)
End If
If Rdr("Master_Child1") = "N" Then
Dim mnuItems As New MenuItem()
NavigationMenu.Items.Remove(mnuItems)
End If
If Rdr("Master_Child2") = "N" Then
Dim mnuItems As New MenuItem()
NavigationMenu.Items.Remove(mnuItems)
End If
---------------
---------------
---------------
---------------
End While
End if
How to disappear the parent and child menu while all the child menu do not have rights...?
推荐答案
这篇关于菜单控件无法正常工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!