首页 > 代码库 > TreeView绑定XmlDataSource
TreeView绑定XmlDataSource
- <?xml version="1.0" encoding="utf-8" ?>
- <movies>
- <category id="category1" text="Action">
- <movie id="movie1" text="Star Wars" />
- <movie id="movie2" text="Independence Day"/>
- </category>
- <category id="category2" text="Horror">
- <movie id="movie3" text="Jaws"/>
- <movie id="movie4" text="Nightmare Before Christmas"/>
- </category>
- </movies>
- <%@ Page Language="C#" %>
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
- <script runat="server">
- </script>
- <html xmlns="http://www.w3.org/1999/xhtml">
- <head runat="server">
- <title></title>
- </head>
- <body>
- <form id="form1" runat="server">
- <div>
- <asp:TreeView ID="TreeView1" runat="server" DataSourceID="srcMovies">
- <DataBindings>
- <asp:TreeNodeBinding DataMember="category" TextField="text" ValueField="id" />
- <asp:TreeNodeBinding DataMember="movie" TextField="text" ValueField="id" />
- </DataBindings>
- </asp:TreeView>
- </div>
- <asp:XmlDataSource ID="srcMovies" runat="server" DataFile="~/MoviesComplex.xml">
- </asp:XmlDataSource>
- </form>
- </body>
- </html>
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。