Create XmlDataSource : XmlDataSource « XML « ASP.NET Tutorial

Home
ASP.NET Tutorial
1.ASP.Net Instroduction
2.Language Basics
3.ASP.net Controls
4.HTML Controls
5.Page Lifecycle
6.Response
7.Collections
8.Validation
9.Development
10.File Directory
11.Sessions
12.Cookie
13.Cache
14.Custom Controls
15.Profile
16.Configuration
17.LINQ
18.ADO.net Database
19.Data Binding
20.Ajax
21.Authentication Authorization
22.I18N
23.Mobile
24.WebPart
25.XML
ASP.NET Tutorial » XML » XmlDataSource 
25.9.1.Create XmlDataSource
<%@ Page Language="C#" AutoEventWireup="true" %>

<!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>XML Data Binding</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
    <asp:XmlDataSource ID="sourceXml" 
                       runat="server"
                       DataFile="data.xml" />
    <asp:GridView ID="GridView1" 
                  runat="server" 
                  AutoGenerateColumns="True"
                  DataSourceID="sourceXml" 
                  Visible="False"/>
    <br />
    <asp:TreeView ID="TreeView1" 
                  runat="server" 
                  DataSourceID="sourceXml">
            <DataBindings>
                <asp:TreeNodeBinding DataMember="SuperProProductList" Text="Product List" />
                <asp:TreeNodeBinding DataMember="Category"  TextField="Name" />
                <asp:TreeNodeBinding DataMember="Product" TextField="Name" />
                <asp:TreeNodeBinding DataMember="Price" TextField="#InnerText" />
            </DataBindings>
        </asp:TreeView>

    </div>
    </form>
</body>
</html>

File: data.xml

<?xml version="1.0" standalone="yes"?>

<SuperProProductList xmlns="SuperProProductList" >
  <Category Name="Hardware">
    <Product ID="1" Name="Chair">
      <Price>49.33</Price>
    </Product>
    <Product ID="2" Name="Car">
      <Price>43398.55</Price>
    </Product>
  </Category>
  <Category Name="Produce">
    <Product ID="3" Name="PC">
      <Price>49.99</Price>
    </Product>
  </Category>
</SuperProProductList>
25.9.XmlDataSource
25.9.1.Create XmlDataSource
25.9.2.Displaying an XML document with the Menu control.
25.9.3.XmlDataSource and XPath
25.9.4.Transform XmlDataSource with XSLT
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.