WebDataTree 使用XML作數據源綁定數據

英文版原文連接:http://www.infragistics.com/help/topic/e5f07b51-ee2d-4a33-aaac-2f43cffff327css

所使用的控件版本爲:Infragistics4.Web.v12.2html

在頁面上拖拽3個控件:ScriptManager,WebDataTree(第三方控件),XmlDataSource,按以下設置:算法

HTML:spa

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Tree.aspx.cs" Inherits="WebStudy.Tree" %>
<%@ Register assembly="Infragistics4.Web.v12.2, Version=12.2.20122.2054, Culture=neutral, PublicKeyToken=7dd5c3163f2cd0cb" namespace="Infragistics.Web.UI.NavigationControls" tagprefix="ig" %>orm

<head>
<link href="Style.css" rel="stylesheet" type="text/css" />
</head>server

<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<ig:WebDataTree ID="WebDataTree1" runat="server"
DataSourceID="XmlDataSource1"
Height="100%"
Width="100%"
Style="float: left; margin-left: 2px"
InitialExpandDepth="0"
EnableConnectorLines="false" StyleSetName="IG">
<DataBindings>
<%--第一層節點綁定,DataMember 節點名字--%>
<ig:DataTreeNodeBinding DataMember="Customer" TextField="CustomerName" ValueField="CustomerID " />
<%-- 第二層節點綁定,DataMember 節點名字 --%>
<ig:DataTreeNodeBinding DataMember="Order" TextField="OrderID" ValueField="OrderID " />
<%-- 第三層節點綁定,DataMember 節點名字 --%>
<ig:DataTreeNodeBinding DataMember="OrderDetail" TextField="ProductName" ValueField="ProductID " />
</DataBindings>
</ig:WebDataTree>
<asp:XmlDataSource ID="XmlDataSource1" runat="server" DataFile="~/test.xml">
</asp:XmlDataSource>
</form>xml

所使用到的XML文件格式以下:htm

<?xml version="1.0" encoding="utf-8" ?>
<Customers>
<Customer CustomerID="ALFKI" CustomerName="A" ImageUrl="NANETLarge.jpg">
<Order OrderID="1024" ImageUrl="NASilLarge.jpg">
<OrderDetail ProductID="1" ProductName="Chocolate" Quantity="10" ImageUrl="NAWinLarge.jpg" />
<OrderDetail ProductID="2" ProductName="Apples" Quantity="20" ImageUrl="NAWpfLarge.jpg" />
<OrderDetail ProductID="3" ProductName="Peanuts" Quantity="30" ImageUrl="NAWinLarge.jpg" />
</Order>
<Order OrderID="1029" ImageUrl="NAAsLarge.jpg">
<OrderDetail ProductID="10" ProductName="Flour" Quantity="100" ImageUrl="NAWinLarge.jpg" />
</Order>
</Customer>
<Customer CustomerID="BLONP" CustomerName="B" ImageUrl="TAWinLarge.jpg">
<Order OrderID="2021" ImageUrl="NASilLarge.jpg">
<OrderDetail ProductID="4" ProductName="Rigatoni" Quantity="30" ImageUrl="NAWpfLarge.jpg"/>
<OrderDetail ProductID="5" ProductName="Ricotta" Quantity="10" ImageUrl="NAWinLarge.jpg" />
</Order>
</Customer>
<Customer CustomerID="WOLZA" CustomerName="C" ImageUrl="NAIcoLarge.jpg">
<Order OrderID="2029" ImageUrl="NASilLarge.jpg">
<OrderDetail ProductID="6" ProductName="Hot Dogs" Quantity="45" ImageUrl="NAWinLarge.jpg" />
<OrderDetail ProductID="7" ProductName="Brown Rice" Quantity="12" ImageUrl="NAWpfLarge.jpg"/>
<OrderDetail ProductID="8" ProductName="Ketchup" Quantity="100" ImageUrl="NAWinLarge.jpg"/>
<OrderDetail ProductID="9" ProductName="Mustard" Quantity="100" ImageUrl="NAWpfLarge.jpg" />
</Order>
</Customer>
</Customers>blog

---------------------------------------------------------------------遞歸

效果圖: 

使用遞歸算法直接綁定數據也是可行的。

參考另外一篇:http://www.cnblogs.com/hiflora/p/3158793.html

相關文章
相關標籤/搜索