1
Answer

Getting exact datapath of a treeview node

varun doharey

varun doharey

14y
2.9k
1
I am binding a Treeview to an XMLDataSource, The databindings are being generated automaticaly, The XML looks like this:-

<Passengers>

  <Passenger type="normal" ethnic="asian">

    <PassengerName>Name1</PassengerName>
  </
Passenger>
 
<Passenger type="normal">
   
<PassengerName>Name2</PassengerName>
  </
Passenger>
 
<Passenger>
   
<PassengerName>Name3</PassengerName>
  </
Passenger>
</Passengers>

The Treeview displays the XML correctly but when i click on a node and the SelectedNodeChanged event fires the SelectedNode.DataPath is always the path to the first passenger in the list no matter which passenger node i click on.

Does anyone know how to get the datapath of the actual node i click on ?


Answers (1)
0
Dipen Lama
NA 331 195.9k 18y
One way to do is create a class called "Users" and have two static variable on it "UserName" and "UserType". Now once you store the variable in this class static variable you can get the value of it from any form.

Let me know if this solve your problem.
0
Dale
NA 15 0 18y
Im new to programming so this might not be right.

but i believe you dont want to create a global variable.

you want to define a method in the same class as your original form that returns The username and one that returns the usertype. 
  implement them somewhere between the constructor and destructor.   Then call it from the second form with a reference to the original class and method.

This is something i am going to try in the near future so im not sure on all of the specifics.  like i said i am new to this, but good luck and let me know if it helps, as i will be trying to do the same thing soon.