注册 登录
编程论坛 VB.NET论坛

关于menu多级菜单栏绑定数据库问题

jianruide 发布于 2019-04-07 18:17, 2315 次点击
各位大侠,menu绑定了数据库,有两表,一个是跟菜单,一个用于子菜单。现在只显示了跟菜单,子菜单显示不出来,求指导!!万分感谢!
da = New OleDbDataAdapter("select * from Department", conn)
            ds = New DataSet
            da.Fill(ds, "MyDepartment")
            DepartmentNum = ds.Tables("MyDepartment").Rows.Count
            Session("DepartmentNum") = DepartmentNum '将部门数量传递给session
            ReDim DepartmentName(DepartmentNum - 1)
            For i = 1 To DepartmentNum
                DepartmentName(i - 1) = ds.Tables("MyDepartment").Rows(i - 1).Item(1).ToString()
                Dim menunode As New MenuItem()   
                menunode.Text = DepartmentName(i - 1)  
                menunode.Value = DepartmentName(i - 1)  
                Menu1.Items.Add(menunode)  

                daTeam = New OleDbDataAdapter("select * from Team Where 部门= '" & DepartmentName(i - 1) & "'", conn)
                dsTeam = New DataSet
                daTeam.Fill(dsTeam, "MyTeam")
                TeamNum = dsTeam.Tables("MyTeam").Rows.Count
                If TeamNum > 0 Then
                    Session(i & "TeamNum") = TeamNum
                    ReDim TeamName(TeamNum - 1)
                    For j = 1 To TeamNum
                        TeamName(j - 1) = dsTeam.Tables("MyTeam").Rows(j - 1).Item(1).ToString

                        Dim menuchildnode As New MenuItem()   
                        menuchildnode.Text = TeamName(j - 1)
                        menuchildnode.Value = TeamName(j - 1)
                        ' Menu1.Items.Add(menuchildnode)   
                        Menu1.Items(0).ChildItems.Add(menuchildnode)  
                    Next j
                End If
            Next i
        End If
1 回复
#2
wangjy5002019-04-22 18:23
test

[此贴子已经被作者于2019-4-22 18:25编辑过]

1