Mega Code Archive

 
Categories / ASP.Net Tutorial / Data Binding
 

The ASP NET 3 5 Framework includes two hierarchical DataBound controls

Menu: Displays data items in a  static or dynamic menu. TreeView: Displays data items in a tree. <%@ 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" > <body>     <form id="form1" runat="server">     <div class="floater">     <h3>TreeView</h3>     <asp:TreeView         id="CheckBoxList1"         DataSourceId="srcData"         Runat="server" />     </div>     <div class="floater">     <h3>Menu</h3>     <asp:Menu         id="BulletedList1"         DataSourceId="srcData"         Runat="server" />     </div>     <asp:XmlDataSource         id="srcData"         DataFile="~/Data.xml"         XPath="/movies/*"         Runat="server" />     </form> </body> </html> File: Data.xml <movies>   <Adventure>     <StarWars />     <JurassicPark />     <IndependenceDay />   </Adventure>   <Animation>     <IceAge />     <Shrek />   </Animation>   <Drama>     <Titanic />     <Ghost />     <ForrestGump />   </Drama>   <Horrer>     <Jaws />     <TheRing />   </Horrer> </movies>