Treeview and hashtables

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • mwcapps
    New Member
    • Mar 2009
    • 16

    #1

    Treeview and hashtables

    I have treeview with checkboxes on it and need to update the database(if unchecked) and insert into the database(if checked) in my button click sub routine. I'm using a hashtable to avoid having 'duplicate keys' in run time. I'm obviously doing something very wrong because the code jumps straight from the 'For each' statement to the 'End Sub' line.

    Code:
    Private Sub cmdUpdate_Click(ByVal sender as System.Object, ByVal e as System.EventArgs) Handles cmdUpdate.Click
    
    Dim sUpdate as String = ""
    Dim node as TreeNode
    
    For each node in tvQuestions.Nodes
        If node.checked Then
            If node.text = htxref.item(tvQuestions.SelectedNode) Then
               sUpdate = "Update............" 'actual SQL statement too long for here
            Else
               sUpdate = "Insert......" 'actual SQL statement too long for here
            End if
        End if
    Next
    
    'SQL execution statements here'
    End Sub
    Last edited by PRR; Jun 12 '09, 05:02 AM. Reason: Post code in [code][/code] tags
  • mzmishra
    Recognized Expert Contributor
    • Aug 2007
    • 390

    #2
    try to use TreeNodeCollect ion
    TreeNodeCollect ion nodes = treeView.Nodes;
    foreach (TreeNode n in nodes)
    {
    }

    Comment

    Working...