Re: XML TreeNode.Parent property when using 2.0 TreeView?
- From: "clintonG" <csgallagher@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Fri, 20 May 2005 16:00:16 -0500
"clintonG" <csgallagher@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:%23erL6WOXFHA.3532@xxxxxxxxxxxxxxxxxxxxxxx
> 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
.
- References:
- XML TreeNode.Parent property when using 2.0 TreeView?
- From: clintonG
- XML TreeNode.Parent property when using 2.0 TreeView?
- Prev by Date: Using XPath with namespaces
- Next by Date: RE: Appending Node to Large XML File
- Previous by thread: XML TreeNode.Parent property when using 2.0 TreeView?
- Next by thread: xml repeater question
- Index(es):
Relevant Pages
|