WebDataTree 使用XML做数据源绑定数据

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

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

在页面上拖拽3个控件:ScriptManager,WebDataTree(第三方控件),XmlDataSource,按如下设置:

HTML:

<%@ 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" %>

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

<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 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>

---------------------------------------------------------------------

效果图:

WebDataTree 使用XML做数据源绑定数据

使用递归算法直接绑定数据也是可行的。

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

上一篇:欧几里得算法(及扩展)&&快速幂(二分+位运算)


下一篇:重置mysql管理员密码