I came up with a solution. Though I might post it if anyone else has the
same problem.
Dim node As TreeNode
Dim arrayIndex As Array
'Check if the newly selected node is a parent of the previously selected
node.
If e.OldNode.Start sWith(e.NewNode ) Then
arrayIndex = e.NewNode.Split ("."c)
'Get the newly selected node.
If arrayIndex.Leng th = 1 Then
node = TreeView.Nodes( arrayIndex(0))
ElseIf arrayIndex.Leng th = 2 Then
node = TreeView.Nodes( arrayIndex(0)). Nodes(arrayInde x(1))
ElseIf arrayIndex.Leng th = 3 Then
node =
TreeView.Nodes( arrayIndex(0)). Nodes(arrayInde x(1)).Nodes(arr ayIndex(2))
End If
'Only bind data to the DataGrid if this isn't a cause of collapsing the
TreeView.
If node.Expanded = True Then
BindData(e.NewN ode)
End If
Else
BindData(e.NewN ode)
End If
"Shawn" <bo********@hot mail.com> wrote in message
news:%2******** ********@TK2MSF TNGP03.phx.gbl. ..
Hi.
The code isn't available right now, it's at work and I'm not going back
until next week.
The code isn't the problem though. I'll try and explain a little more.
In page_load the whole tree is generated. If I expand a node then nothing
is being done. If I click on a node then a DataGrid is filled based on the
node beeing clicked. This is done by calling my BindData() method from the
method that handles the SelectedNodeCha nged event. That's it really, and it
workes like a charm.
Now, to the problem. If a node is selected and I click to collapse it's
parent node then the parent node becomes selected and the
SelectedNodeCha nged event fires. This causes my DataGrid to fill up with new
data based on the parent node that is now selected. I don't want that to
happen since I haven't clicked on a node, I've just collapsed it.
I'm unable to tell whether a node has been selected or just collapsed. If
there is a way to know this then I could prevent the DataGrid from being
filled up with new data.
Shawn
"Patrick.O. Ige" <na********@hot mail.com> wrote in message
news:e8******** ******@TK2MSFTN GP02.phx.gbl...
Shawn maybe u can post some snippet code.
Patrick
"Shawn" <bo********@hot mail.com> wrote in message
news:%2******** **********@TK2M SFTNGP04.phx.gb l...
Hi.
I'm working with the TreeView control in my ASP.NET 1.1 application. I
have
a problem I haven't been able to figure out. When I click on a node (not
expand), whether it's a parent node, a child node or a leaf node then a
DataGrid is populated based on the node's ID property. If I expand a node
then the DataGrid is not populated. This works fine. The problem is that
this doesn't work if I collapse the tree. If I collapse the tree then the
collapsed node is being selected (if the currently selected node is a
subnode of the node being collapsed) and the SelectedNodeCha nged event is
fired. This causes the DataGrid to populate again. I've been thinking of
a
way to avoid this, but I'm all out of ideas.
I thought of setting a flag when the collapse event was fired and then
check
for that flag when the SelectedNodeCha nged event fired to avoid populating
the DataGrid again. Problem is that the SelectedNodeCha nged event fires
before the collapse event.
So, if there are any bright minds out there who can tell me what to do I
would be very grateful.
Thanks,
Shawn