Getting exact datapath of a treeview node
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</PassengerNa开发者_StackOverflow社区me>
</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 ?
It's because you have master page. so when you select a node it comes first to the pageload function in the current page, there you can see the real selected node, and then it goes to the pageLoad function in the master page and come back to the selectedNodeChanged function in the page where you have the treeview, but cause it went before to the master page the selected node was forgotten... you have to save the selectednode (by viewstate or something else...) in the pageLoad function of the content page, and then take it off in the selectedNodeChanged function.
精彩评论