D
Derek Pettinato
Hi,
I have a treeview on a webform bound to an external XML
file with checkboxes.
I have some javascript on the page that basically fires
when the checkboxes are checked to uncheck anything that
may be checked in the same node thus allowing only one
node to be checked at one time.
On this form I have a submit button that run some vb
codebehind. All I need this codebehind to do is to go
through the entire treeview and grab all of the items
that are checked. I figured this would be pretty easy
with the .checked property. Not the case as when
debugging the codebehind, the checked value of the node I
checked is always false.
Also, I cannot have the javascript do this as I need to
run back to the server to populate dynamically generated
tables with the data that is checked on the treeview.
My code is below...
'**********button clicked***************
Public Sub TreeSelect(ByVal sender As System.Object,
ByVal e As
Microsoft.Web.UI.WebControls.TreeViewSelectEventArgs)
Dim dimArray() As String
ReDim dimArray(TreeView1.Nodes.Count)
For i = 0 To TreeView1.Nodes.Count - 1
dimArray(i) = ProcessNodes(TreeView1.Nodes)
Next
'**************************************
'********function*************************
Public Function ProcessNodes(ByVal ParentNode As
TreeNodeCollection) As String
Dim childNode As TreeNode
For Each childNode In ParentNode
If childNode.Checked = True Then
ProcessNodes = childNode.Text
End If
If childNode.Nodes.Count > 0 Then
If childNode.Checked = False Then
ProcessNodes(childNode.Nodes)
Else 'checked!
ProcessNodes = childNode.Text
End If
End If
Next childNode
'*********************************
Thank you in advance,
-Derek.
I have a treeview on a webform bound to an external XML
file with checkboxes.
I have some javascript on the page that basically fires
when the checkboxes are checked to uncheck anything that
may be checked in the same node thus allowing only one
node to be checked at one time.
On this form I have a submit button that run some vb
codebehind. All I need this codebehind to do is to go
through the entire treeview and grab all of the items
that are checked. I figured this would be pretty easy
with the .checked property. Not the case as when
debugging the codebehind, the checked value of the node I
checked is always false.
Also, I cannot have the javascript do this as I need to
run back to the server to populate dynamically generated
tables with the data that is checked on the treeview.
My code is below...
'**********button clicked***************
Public Sub TreeSelect(ByVal sender As System.Object,
ByVal e As
Microsoft.Web.UI.WebControls.TreeViewSelectEventArgs)
Dim dimArray() As String
ReDim dimArray(TreeView1.Nodes.Count)
For i = 0 To TreeView1.Nodes.Count - 1
dimArray(i) = ProcessNodes(TreeView1.Nodes)
Next
'**************************************
'********function*************************
Public Function ProcessNodes(ByVal ParentNode As
TreeNodeCollection) As String
Dim childNode As TreeNode
For Each childNode In ParentNode
If childNode.Checked = True Then
ProcessNodes = childNode.Text
End If
If childNode.Nodes.Count > 0 Then
If childNode.Checked = False Then
ProcessNodes(childNode.Nodes)
Else 'checked!
ProcessNodes = childNode.Text
End If
End If
Next childNode
'*********************************
Thank you in advance,
-Derek.