XML
Before going into database binding, we'll look at XML because it's probably the most common way to bind data to a TreeView. This time, we will use the TreeNodeSrc attribute and static XML file to create the Parent Child structure of our tree.
Create the following XML file called XMLFile1.xml and save it in the same directory as your TreeView aspx file.
<TREENODES>
<treenode text="Partent1">
<treenode text="Child-1a"/>
<treenode text="Child-1b"/>
</treenode>
<treenode text="Partent2">
<treenode text="Child-2a"/>
<treenode text="Child-2b"/>
</treenode>
</TREENODES>
The XML root element must be upper case and named <TREENODES> for the bind to work. If your XML will be coming from a source where you cannot control the root name and structure, an XLS sheet can be used to translate your formatting. The following error will be produced if the correct root is not used.
|