编程语言

img feishi_001

TreeView&CheckBox(ASP.NET)

发表于2004/10/20 14:22:00  713人阅读

分类: ing……

首先设置TreeView的属性AutoPostBack="True",这样才会有Onchange="TreeView2_ChkChange" 的有效。
    Sub TreeView2_ChkChange(ByVal sender As Object, ByVal e As TreeViewClickEventArgs) Handles TreeView2.Check
        CheckAllChildNodes(TreeView2.GetNodeFromIndex(e.Node), True)
        Session("Groups") = NodeShow(TreeView2.Nodes)
        Response.Write("Session=" & Session("Groups"))
    End Sub
    Sub CheckAllChildNodes(ByVal treeNode As TreeNode, ByVal nodeChecked As Boolean)
        Dim node As TreeNode
        For Each node In treeNode.Nodes
            node.Checked = nodeChecked
            If node.Checked = True Then
                If node.Nodes.Count > 0 Then
                    Me.CheckAllChildNodes(node, nodeChecked)
                End If
            End If
        Next
    End Sub
   Function NodeShow(ByVal treeNode As TreeNodeCollection) As String
        Dim node As TreeNode
        For Each node In treeNode
            If node.CheckBox Then
                If node.Checked Then
                    strGroupIds = strGroupIds & node.Text & ","
                End If
                If node.Nodes.Count > 0 Then
                    NodeShow(node.Nodes)
                End If
            End If
        Next
        Return strGroupIds
    End Function
阅读全文
0 0

相关文章推荐

img
取 消
img