ROOT
A
B
C
D
E
T
F
G
X
I want to find E Node's parent nodes(it is number 5). Then, I'll save node. If number is smaller 5. I'm using TreeView in Asp.net control.
ROOT
A
B
C
D
E
T
F
G
X
I want to find E Node's parent nodes(it is number 5). Then, I'll save node. If number is smaller 5. I'm using TreeView in Asp.net control.
I would suggest using recursive iterations.
You can utilize this logic to determine many things about you node and this structure also allows you to expand what you can do with the node and the criteria you wish to search for. You can edit my example to fit your own needs.
Thus, with this example you could pass in E and expect to have the node E returned then simply if the parent property of the node returned would be the parent you are after.
tn.parent
is the value you are after.I'm curious, since this is tagged as a WebForm, why Microsoft's FindNode method was not suggested. It is compatible from v2.0 up to now (currently v4.5.2).
Does that not work here?
From Microsoft's MSDN:
Example: