I built a treeview from a datatable, but I am not understanding fully. I could not find anywhere to tell it what the id was going to be. My now I am showing has an associated ID. How do I assign this ID no the child nodes and then how do I pull out the id of the child node they clicked on?
Any help would be much appreciated.
- Lisa
Loading
Scott LyslePosted Apr 13, 2007, 11:44 PM
Using the option that you are showing, you are setting the key value (which is the name property of the node) and the Text property of the node (which is the text that appears in the treeview adjacent to the node).
In the standard treenode, you may set or get the name, text, and tag values for each node. When you say ID, I assume that you mean what you are showing as being populated with the Registration ID. That is, in the case, accessible through the name property of the node.
Given the names of the columns it might seem confusing but RegisrationID is the node's name, and Name is the node's text. tv.SelectedNode.Name should be what your are looking for if you are looking for the registration ID value.
Lisa MPosted Apr 13, 2007, 8:36 AM
{
node = tvOffender.Nodes.Add(row["Name"].ToString());
foreach (DataRow row2 in dtData2.Rows)
{
child = node.Nodes.Add(row2["RegistrationID"].ToString(), row2["Name"].ToString());
}
}
Can someone help? How do I get the ID of the selected node? tv.SelectedNode.value does not exist.. I am getting desperate!