<%@ Control Language="c#" AutoEventWireup="false" %>
<%@ Register TagPrefix="ec" Namespace="ASPNETExpert.WebControls" Assembly="ASPNETExpert.WebControls" %>
<%@ Register TagPrefix="ecd" Namespace="ASPNETExpert.WebControls.DemoControls" Assembly="ASPNETExpert.WebControls.DemoControls" %>
<table cellpadding="0" cellspacing="5" border="0" xmlns:ec="urn:http://aspnetexpert.com/ExpertControls.xsd">
<tr>
<td valign=top>
<table cellpadding="0" cellspacing="0" border="0">
<tr>
<td>
<ec:ExpertTree id="PopulateOnDemandXmlBoundTree" runat="server" DataSourceID="BookXmlDataSource" Skin="XP" ExpandOnClick="true" CollapseOnClick="true">
<TreeLook Width="180" Height="320px" Overflow="Scroll" />
<DataBindings>
<ec:DataBinding DataMember="Book">
<PropertyBindings>
<ec:PropertyBinding Property="Text" DataField="Title" />
<ec:PropertyBinding Property="PopulateOnDemand" Value="True" />
</PropertyBindings>
</ec:DataBinding>
<ec:DataBinding DataMember="Chapter">
<PropertyBindings>
<ec:PropertyBinding Property="Text" DataField="Heading" />
<ec:PropertyBinding Property="PopulateOnDemand" Value="True" />
</PropertyBindings>
</ec:DataBinding>
<ec:DataBinding DataMember="Section">
<PropertyBindings>
<ec:PropertyBinding Property="Text" DataField="Heading" />
</PropertyBindings>
</ec:DataBinding>
</DataBindings>
</ec:ExpertTree>
<asp:XmlDataSource id="BookXmlDataSource" DataFile="../Data/Book.xml" runat="server" />
</td>
</tr>
</table>
</td>
<td valign=top style="padding-left:10px;">
<ecd:DescriptionView ID="DescriptionView1" runat="server">
<ecd:Description ID="Description1" runat="server">This demo shows how to bind <b>ExpertTree</b>
to a <b>XmlDataSource</b> control and auto-populate the tree on demand.</ecd:Description>
<ecd:Description ID="Description2" runat="server">All you need to do for this is to set tree's
<b>DataSourceID</b> property to the ID of the <b>XmlDataSource</b> control and define a number
of <b>DataBinding</b>s and nested <b>PropertyBinding</b>s to map tree nodes to data members and
data fields and define <b>PropertyBinding</b> for <b>PopulateOnDemand</b> property with <b>Value="True"</b>.
</ecd:Description>
<ecd:Description ID="Description4" runat="server">Here three <b>DataBinding</b>s are defined for
three different XML elements named Book, Chapter and Section. Every DataBinding also defines
how tree node properties bind to Xml attributes. The first two levels also bind <b>PopulateOnDemand</b>
property to <b>True</b>.
<pre class="aspcode">
<ecd:SyntaxHighlight ID="SyntaxHighlight3" runat="server" ContentType="ASPX">
<DataBindings>
<ec:DataBinding DataMember="Book">
<PropertyBindings>
<ec:PropertyBinding Property="Text" DataField="Title" />
<ec:PropertyBinding Property="PopulateOnDemand" Value="True" />
</PropertyBindings>
</ec:DataBinding>
<ec:DataBinding DataMember="Chapter">
<PropertyBindings>
<ec:PropertyBinding Property="Text" DataField="Heading" />
<ec:PropertyBinding Property="PopulateOnDemand" Value="True" />
</PropertyBindings>
</ec:DataBinding>
<ec:DataBinding DataMember="Section">
<PropertyBindings>
<ec:PropertyBinding Property="Text" DataField="Heading" />
</PropertyBindings>
</ec:DataBinding>
</DataBindings>
</ecd:SyntaxHighlight>
</pre>
</ecd:Description>
<ecd:Description ID="Description5" runat="server">You can define a number of <b>PropertyBinding</b>s
to map additional node properties to other Xml attributes or assign them arbitrary values.</ecd:Description>
<ecd:Description ID="Description6" runat="server">You can also define a handler for
<b>ItemDataBound</b> server-side event for fine tuning the bound properties or even
cancel creating the node.</ecd:Description>
<ecd:Description runat="server">
<b>PopulateOnDemandViewStateEnabled</b> property controls whether the tree view state is kept
up-to-date between server callbacks. If <b>PopulateOnDemandViewStateEnabled</b> is turned on,
(by default, it is), disable event validation for the page:
<pre class="aspcode">
<ecd:SyntaxHighlight ID="SyntaxHighlight4" runat="server" ContentType="ASPX">
<%@ Page EnableEventValidation="false" %>
</ecd:SyntaxHighlight>
</ecd:Description>
</ecd:DescriptionView>
</td>
</tr>
</table>
<ec:CodeViewTab id="CodeViewTab1" runat="server">
<ec:TabItem ID="TabItem1" runat="server" Text="aspx">
<pre class="aspcode">
<ecd:SyntaxHighlight ID="SyntaxHighlight1" runat="server" ContentType="ASPX" OutputFile="Advanced/BindToXmlPopulateOnDemand.ascx" />
</pre>
</ec:TabItem>
<ec:TabItem ID="TabItem2" runat="server" Text="Book.xml">
<pre class="aspcode">
<ecd:SyntaxHighlight ID="SyntaxHighlight2" runat="server" ContentType="XML" OutputFile="Data/Book.xml" />
</pre>
</ec:TabItem>
</ec:CodeViewTab>
<?xml version="1.0" encoding="utf-8" ?>
<Book Title="Book Title">
<Chapter Heading="Chapter 1">
<Section Heading="Section 1">
</Section>
<Section Heading="Section 2">
</Section>
</Chapter>
<Chapter Heading="Chapter 2">
<Section Heading="Section 1">
</Section>
</Chapter>
</Book>