Source view of XMLDATASOURCE.ASPX
DotNet Funda: Code Viewer
xmldatasource.aspx | xmldatasource.aspx.cs
Close Window  
<asp:Content ID="Content1" ContentPlaceHolderID="PlaceHolderHeader" Runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="PlaceHolderForTitleAndIntro" Runat="Server">
    <table width="100%" cellpadding="2" cellspacing="0">
        <tr valign="top" class="ArticleTitle">
            <td style="padding-left:10px;" valign="middle">
                asp:XmlDataSource control</td>
        </tr>
        <tr>
            <td class="ArticleContents">
                The XmlDataSource control is a unique data source control that support both tabular and hierarchical views of data.
            </td>
        </tr>
        <tr>
            <td colspan="2">&nbsp;</td>
        </tr>
    </table>
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="PlaceHolderForContents" Runat="Server">
    <div class="ArticleContents">
        The XmlDataSource control is a unique data source control that support both tabular and hierarchical views of data.
        Unlike other DataSource Control, this control only support read-only methods.
               
        <br /><br />        
        <table width="100%" class="TutoPropPlaceHolder" border="1" cellpadding="2" cellspacing="1">
            <tr>
                <th colspan="2" align="left">
                   Some Important Properties of XmlDataSource Control
                </th>
            </tr>
            <tr>
                <td class="DemoCP">Data</td>
                <td>
                    Gets or sets the blcok of XML contents text to bind to the target control.
                </td>
            </tr>
            <tr>
                <td class="DemoCP">DataFile</td>
                <td>
                    XML File path used to display bind data to target controls.
                </td>
            </tr>
            <tr>
                <td class="DemoCP">XPath</td>
                <td>
                    Gets an XPath query to apply on XML data.
                </td>
            </tr>
            <tr>
                <td class="DemoCP">Transform</td>
                <td>
                    Block of XSLT text that is used to transform data.
                </td>
            </tr>
            <tr>
                <td class="DemoCP">TransformFile</td>
                <td>
                    XSL File path that defines the transformation to be applied on XML file.
                </td>
            </tr>
            <tr>
                <td class="DemoCP">EnableCaching</td>
                <td>
                    true/false. Whether to enable caching or not.
                </td>
            </tr>
            <tr>
                <td class="DemoCP">CacheDuration</td>
                <td>
                    Number of seconds, data to be maintained in the cache.
                </td>
            </tr>
            <tr>
                <td class="DemoCP">CacheExpirationPolicy</td>
                <td>
                    Absolute/Sliding. Cache policy to be applied on. <br />
                    Absolute: The data is removed after specified duration. Sliding: The data is removed if it is not used for specified duration.
                </td>
            </tr>
        </table>
        <!-- START - Demo Section -->
        <table class="DemoPlaceHolder" border="1" cellpadding="2" cellspacing="4">
            <tr>
                <td class="DemoTitle">
                    DEMO : ObjectDataSource
                </td>
                <td align="right">
                    <a class="DemoShowSource" href="../../misc/codeviewer/default.aspx?pagename=~/tutorials/controls/xmldatasource.aspx" target="_blank">Show Source Code</a>
                </td>
            </tr>
            <tr>
                <td>
                    <asp:TreeView ID="TreeView1" runat="server" DataSourceID="XmlDataSource1">
                        <DataBindings>
                            <asp:TreeNodeBinding TextField="#innertext" DataMember="Name" /> 
                            <asp:TreeNodeBinding TextField="#innertext" DataMember="From" />
                        </DataBindings>
                    </asp:TreeView>
                    
                    <asp:XmlDataSource ID="XmlDataSource1" runat="Server" DataFile="~/tutorials/controls/controldata/XMLFile.xml"
                     XPath="DotNetFunda/Writers">
                    </asp:XmlDataSource>
                    
                </td>
                <td>
                    For more on XML see <a href="xml.aspx">XML Control</a>
                </td>
            </tr>
            <tr>
                <td colspan="2">
                    <!-- START - Server Side Code -->
                    <pre>                    
                    
// TreeView Control ///////////////////////////////
&lt;asp:TreeView ID="TreeView1" runat="server" DataSourceID="XmlDataSource1"&gt;
        &lt;DataBindings&gt;
            &lt;asp:TreeNodeBinding TextField="#innertext" DataMember="Name" /&gt; 
            &lt;asp:TreeNodeBinding TextField="#innertext" DataMember="From" /&gt;
        &lt;/DataBindings&gt;
    &lt;/asp:TreeView&gt;

// XmlDataSource Control ///////////////////////////////
    &lt;asp:XmlDataSource ID="XmlDataSource1" runat="Server" DataFile="~/tutorials/controls/controldata/XMLFile.xml"
     XPath="DotNetFunda/Writers"&gt;
    &lt;/asp:XmlDataSource&gt;

// XML File ///////////////////////////////
&lt;DotNetFunda&gt;
  &lt;Writers&gt;
    &lt;Name&gt;Sheo Narayan&lt;/Name&gt;
    &lt;From&gt;Hyderabad, India&lt;/From&gt;
  &lt;/Writers&gt;
  &lt;Writers&gt;
    &lt;Name&gt;Vijay Bandaru&lt;/Name&gt;
    &lt;From&gt;Virginia, USA&lt;/From&gt;
  &lt;/Writers&gt;
  &lt;Writers&gt;
    &lt;Name&gt;Jay Shankar&lt;/Name&gt;
    &lt;From&gt;Aurangabad, India&lt;/From&gt;
  &lt;/Writers&gt;
  &lt;Writers&gt;
    &lt;Name&gt;Dr. Sunita Narayan&lt;/Name&gt;
    &lt;From&gt;Bokaro, India&lt;/From&gt;
  &lt;/Writers&gt;
  &lt;Writers&gt;
    &lt;Name&gt;Sunil Kumar Prasad&lt;/Name&gt;
    &lt;From&gt;Ranchi, India&lt;/From&gt;
  &lt;/Writers&gt;
  &lt;Writers&gt;
    &lt;Name&gt;Sunita Shankar&lt;/Name&gt;
    &lt;From&gt;Daudnagar, India&lt;/From&gt;
  &lt;/Writers&gt;
&lt;/DotNetFunda&gt;


                    </pre> 
                    <!-- END - Server Side Code -->
                </td>
            </tr>
        </table>
        <!-- END - Demo Section -->
        </div>
    <br />
</asp:Content>
<asp:Content ID="Content4" ContentPlaceHolderID="PlaceHolderFooter" Runat="Server">
</asp:Content>

Go Top