asp.net TreeView 遍历。
发布网友
发布时间:2022-05-24 00:19
我来回答
共2个回答
热心网友
时间:2024-12-05 13:27
List<User> users=UM.Find();//查找得出所有的用户信息
int count=users.count();
for(int i=0;i<count;l){
TreeNode TreeNode=new TreeNode();
treeNode.Text=users.Name
this.TreeView.Nodes.add(TreeNode)
}
热心网友
时间:2024-12-05 13:28
前台定义一个TREEVIEW2
<asp:TreeView ID="TreeView2" runat="server" Font-Bold="False" Font-Size="14px"
Height="100%" ImageSet="Inbox" ShowLines="True" Width="100%">
<ParentNodeStyle Font-Bold="False" />
<HoverNodeStyle Font-Underline="True" />
<SelectedNodeStyle Font-Underline="True" HorizontalPadding="0px"
VerticalPadding="0px" />
<NodeStyle Font-Names="Verdana" Font-Size="8pt" ForeColor="Black"
HorizontalPadding="5px" NodeSpacing="0px" VerticalPadding="0px" />
</asp:TreeView>
后台读取数据库后循环
Dim a As New TreeNode()
a.Text = "联系人"
a.NavigateUrl = "#"
TreeView2.Nodes.Add(a)
While ora_read.Read()
Dim b As New TreeNode()
b.Value = ora_read.Item("GH")
b.NavigateUrl = "javascript:ShowMessage(0,'" & b.Value & "');"
b.Text = ora_read.Item("GH
TreeView2.Nodes.Item(0).ChildNodes.Item(ChildFlag - 1).ChildNodes.Add(b)
End While