Subscribe

RSS Feed (xml)

Data-binding a TreeView Control

If you have not worked with the TreeView control before, refer to section 3.8 for basic
TreeView information. First, you need to add the TreeView to your page and set the
treenodesrc property to the XML file that you’ll be creating.
<mytree:treeview runat=”server” id=”myTree” treenodesrc=”cars.XML”>
</mytree:treeview>

The next thing you need to do is create your XML file that you will use to bind the
TreeView to:
<?xml version=”1.0” encoding=”utf-8” ?>
<TREENODES>
<treenode text=”Cars”>
<treenode text=”Ford” />
<treenode text=”Toyota” />
<treenode text=”Infiniti” />
</treenode>
</TREENODES>
When the page loads, the TreeView will generate its nodes from the XML file.

It is not possible to directly data-bind a dataset to the TreeView Web Control.The data
must first be translated to XML.You can use response.write, which writes the XML,
or use XSLT to transform the dataset into the correct XML.When using XSLT, you can
specify the XSLT file using the TreeNodeXsltSrc property of the TreeView. In addition
to using XML to define the actual nodes of the TreeView, you can also use XML to
define the style types by using the TreeNodeTypeSrc property of the TreeView control.

No comments:

Archives

Variety in the Web World