Connecting Tech Pros Worldwide Help | Site Map

Treeview and hashtables

Newbie
 
Join Date: Mar 2009
Posts: 16
#1: Jun 10 '09
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.

Expand|Select|Wrap|Line Numbers
  1. Private Sub cmdUpdate_Click(ByVal sender as System.Object, ByVal e as System.EventArgs) Handles cmdUpdate.Click
  2.  
  3. Dim sUpdate as String = ""
  4. Dim node as TreeNode
  5.  
  6. For each node in tvQuestions.Nodes
  7.     If node.checked Then
  8.         If node.text = htxref.item(tvQuestions.SelectedNode) Then
  9.            sUpdate = "Update............" 'actual SQL statement too long for here
  10.         Else
  11.            sUpdate = "Insert......" 'actual SQL statement too long for here
  12.         End if
  13.     End if
  14. Next
  15.  
  16. 'SQL execution statements here'
  17. End Sub
  18.  
Expert
 
Join Date: Aug 2007
Location: nj,usa
Posts: 299
#2: Jun 16 '09

re: Treeview and hashtables


try to use TreeNodeCollection
TreeNodeCollection nodes = treeView.Nodes;
foreach (TreeNode n in nodes)
{
}
Reply

Tags
hash tables, tree views