Mega Code Archive

 
Categories / ASP.Net / XML
 

TreeNode Binding

<%@ Page Language="C#" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" > <head runat="server">     <title>Untitled Page</title> </head> <body>     <form id="form1" runat="server">     <div>         <asp:XmlDataSource ID="XmlDataSource1" runat="server" DataFile="Data.xml" />         <asp:TreeView DataSourceID="XmlDataSource1"                        ID="TreeView1"                        ImageSet="WindowsHelp"                       runat="server">             <ParentNodeStyle Font-Bold="False" />             <SelectedNodeStyle BackColor="#B5B5B5"                                 Font-Underline="False"                                 HorizontalPadding="0px"                                VerticalPadding="0px" />             <DataBindings>                 <asp:TreeNodeBinding DataMember="book" TextField="Name" />                 <asp:TreeNodeBinding DataMember="Publisher" TextField="PublisherName" />                 <asp:TreeNodeBinding DataMember="Author" TextField="Name" />             </DataBindings>             <NodeStyle Font-Names="Tahoma"                         Font-Size="8pt"                         ForeColor="Black"                         HorizontalPadding="5px"                        NodeSpacing="0px"                         VerticalPadding="1px" />             <HoverNodeStyle Font-Underline="True" ForeColor="#6666AA" />         </asp:TreeView>     </div>     </form> </body> </html> File: Data.xml <?xml version="1.0" encoding="utf-8" ?> <Books>   <book Name="Programming C#">     <Author Name = "AAA" />     <Publisher PublisherName = "publisher 1" />   </book>   <book Name="Programming ASP.NET">     <Author Name = "AAA" />     <Author Name = "Dan Hurwitz" />     <Publisher PublisherName = "publisher 1" />   </book>   <book Name="Visual C# Notebook">     <Author Name = "AAA" />     <Publisher PublisherName = "publisher 1" />   </book> </Books>