Bind inline XML datasource to asp treeview : XML TreeView « XML « ASP.Net






Bind inline XML datasource to asp treeview

<%@ Page Language="C#" %>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
    <title>Using Inline XML Data in an XmlDataSource Control</title>
</head>
<body>    
    <form id="form1" runat="server">
    <div>
        <asp:TreeView ID="TreeView1" Runat="server" DataSourceID="XmlDataSource1">
            <DataBindings>
                <asp:TreeNodeBinding ImageUrl="openbook.gif" TextField="Title" DataMember="book"></asp:TreeNodeBinding>
                <asp:TreeNodeBinding ImageUrl="notepad.gif" TextField="name" DataMember="chapter"></asp:TreeNodeBinding>
            </DataBindings>
        </asp:TreeView>    
    </div>
        <div>
            <asp:XmlDataSource ID="XmlDataSource1" Runat="server" XPath="bookstore/book">
                <Data>                    
                    <bookstore>
                        <book Title="title 1" Price="19.99">
                            <chapter num="1" name="Introduction">
                                A
                            </chapter>
                            <chapter num="2" name="Body">
                                B
                            </chapter>
                            <chapter num="3" name="Conclusion">
                                C
                            </chapter>
                        </book>
                        <book Title="title 2" Price="24.95">
                            <chapter num="1" name="Introduction">
                                D
                            </chapter>
                            <chapter num="2" name="Body">
                                E
                            </chapter>
                            <chapter num="3" name="Conclusion">
                                F
                            </chapter>
                        </book>   
                    </bookstore>
                </Data>
            </asp:XmlDataSource>
        </div>
    </form>
</html>

           
       








Related examples in the same category

1.Build tree out of the XML data file
2.asp:TreeView binded to XML transformation data
3.asp TreeView data binding to XML data
4.XML data binding?
5.detailed XML data binding
6.TreeNode Binding