在Web应用程序中将XML转换为TreeView [英] XML to TreeView in web application
本文介绍了在Web应用程序中将XML转换为TreeView的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要从xml填充值以加载树形视图.
I need to populate the values from xml to load the treeview .
推荐答案
1)创建一个XML文件,然后将&将TreeView控件拖放到该页面上,然后单击treeview控件的智能导航器,选择数据源作为
XmlDataSource,选择XML文件路径.
例子
1) create one XML file then drag & drop TreeView control on to the page and click on smart navigator of treeview control ,choose data source as a
XmlDataSource,select the XML File Path.
Example
MenuXML.xml
<code>
<?xml version="1.0" encoding="utf-8" ?>
<Root>
<Parent1>
<Child1></Child1>
<Child2></Child2>
</Parent1>
<Parent2>
<Child1></Child1>
<Child2></Child2>
<Child3></Child3>
</Parent2>
</Root>
</code>
在网页中
In a web page
<br />
<pre><br />
<asp:treeview id="TreeView1" runat="server" datasourceid="XmlDataSource1" imageset="XPFileExplorer" nodeindent="15" xmlns:asp="#unknown"><br />
<parentnodestyle font-bold="False" /><br />
<hovernodestyle font-underline="True" forecolor="#6666AA" /><br />
<selectednodestyle backcolor="#B5B5B5" font-underline="False"><br />
HorizontalPadding="0px" VerticalPadding="0px" /><br />
<nodestyle font-names="Tahoma" font-size="8pt" forecolor="Black"><br />
HorizontalPadding="2px" NodeSpacing="0px" VerticalPadding="2px" /><br />
</nodestyle></selectednodestyle></asp:treeview><br /><br />
<asp:xmldatasource id="XmlDataSource1" runat="server" datafile="~/MenuFile.xml" xmlns:asp="#unknown" /><br />
<br />
</pre><br />
<br />
<br />
看这里:
MSDN:如何在Visual C#2005或Visual C#.NET中用XML数据填充TreeView控件 [ ^ ]
Look here:
MSDN: How to populate a TreeView control with XML data in Visual C# 2005 or in Visual C# .NET[^]
这篇关于在Web应用程序中将XML转换为TreeView的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文