Click here to Skip to main content
15,891,184 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I need to populate the values from xml to load the treeview .
Posted

1) create one XML file then drag & drop TreeView control on to the page and click on smart navigator of treeview control ,choose data source as a
XmlDataSource,select the XML File Path.

Example

MenuXML.xml

<code>
<?xml version="1.0" encoding="utf-8" ?>
<Root>
	<Parent1>
		<Child1></Child1>
		<Child2></Child2>
	</Parent1>
	<Parent2>
		<Child1></Child1>
		<Child2></Child2>
		<Child3></Child3>
	</Parent2>

</Root>
</code>


In a web page

<asp:treeview id="TreeView1" runat="server" datasourceid="XmlDataSource1" imageset="XPFileExplorer" nodeindent="15" xmlns:asp="#unknown">
        <parentnodestyle font-bold="False" />
        <hovernodestyle font-underline="True" forecolor="#6666AA" />
        <selectednodestyle backcolor="#B5B5B5" font-underline="False">
            HorizontalPadding="0px" VerticalPadding="0px" />
        <nodestyle font-names="Tahoma" font-size="8pt" forecolor="Black">
            HorizontalPadding="2px" NodeSpacing="0px" VerticalPadding="2px" />
    </nodestyle></selectednodestyle></asp:treeview><br />
    <asp:xmldatasource id="XmlDataSource1" runat="server" datafile="~/MenuFile.xml" xmlns:asp="#unknown" />
 
Share this answer
 
Comments
Kavithadevarajan.21 21-Jun-10 12:37pm    
It is working fine,but populating with all the values from xml.can u provide solution to the same.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900