#2
wangjy5002019-04-22 18:23
|
各位大侠,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