I need your support because I have got very difficult problem. I would like to take attribute using TreeView1.SelectedNode but I do not know what should I write there to get attribute.
This is my Xml tree:
<?xml version="1.0" encoding="utf-8"?>
<ubrania>
<damska>
<nk id="Nowa Kolekcja">
<item>
<id>1</id>
</item>
<item>
<id>2</id>
</item>
</nk>
<pm id="Nowosci">
<item>
<id>3</id>
</item>
<item>
<id>4</id>
</item>
</pm>
</damska>
</ubrania>
IF I will write this: (when I will click on node “nk” I get only value “nk” but I need attribute “Nowa Kolekcja” when I will click on “nk”)
protected void TreeView1_SelectedNodeChanged2(object sender, EventArgs e)
{
Label2.Text = TreeView1.SelectedNode.Value;
}
I assume you are using asp:XmlDataSource and asp:TreeView. you have to setup for the Value of TreeNode.
Following is my test code:
TextField=”#Name” means displaying element name.
ValueField=”id” means set Value of TreeNode as the content of id attribute.
C# code is simple: