By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
457,731 Members | 1,055 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 457,731 IT Pros & Developers. It's quick & easy.

XML TreeNode.Parent property when using 2.0 TreeView?

P: n/a
How do I get a TreeNode.Parent property when using the 2.0 TreeView control?

When the data source is an XML file there may be redundant names in the
tree. For example, when a child node with the value of 'name' is selected I
don't have a clue how to get the name of its parent which may be 'person' or
'school.'

<%= Clinton Gallagher
Nov 12 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
"clintonG" <cs*********@REMOVETHISTEXTmetromilwaukee.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
How do I get a TreeNode.Parent property when using the 2.0 TreeView
control?

When the data source is an XML file there may be redundant names in the
tree. For example, when a child node with the value of 'name' is selected
I
don't have a clue how to get the name of its parent which may be 'student'
or
'school.'

<%= Clinton Gallagher


One mystery solved...

if(treeView1.SelectedNode.Parent.Depth != -1)
{
lblSelectedNode.Text =
"Parent Node: " + treeView1.SelectedNode.Parent.Text + " " +
"SelectedNode: " + treeView1.SelectedNode.Value.ToString() + " " +
}
else
{
// do something else here
}

Now the next mystery is how to determine *which* parent and child have been
selected when there are multiple parents and children all of which are
redundantly named...

<school>
<name>School of Hard Knocks</name>
<student>
<name>John</name>
</student>
<student>
<name>Jane</name>
</student>
</school>

For example, when the <name> node with value of John is selected I can now
get and pass the values from the parent <student> and the child <name> nodes
as &parent=student&name=John easily enough but I'm wondering if that's the
smartest way to identify the group of nodes in a tree or if there is some
indexing methodology that would be more efficient, more readable, and not
require what it seems will require a quite lengthy switch statement in the
page that receives the passed QueryString values.

For example, the example tree shown above is simplified. The actual parent
<student> will have several children such as <name>,<age>, <sex> and
possibly other child nodes for example. The root node <school> will have
multiple instances of the <student> nodes.

What I am working on is the use of a tree that can allow a node to be
selected and then passed to a page where textboxes can be used to populate
the node with data or edit the existing data for the node. I need help
understanding how to explicilty identify which parent-child nodes have been
selected when the tree contains redundantly named instances.

Comments?

<%= Clinton Gallagher
Nov 12 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.