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.
Some Important Properties of XmlDataSource Control
|
Data |
Gets or sets the blcok of XML contents text to bind to the target control.
|
DataFile |
XML File path used to display bind data to target controls.
|
XPath |
Gets an XPath query to apply on XML data.
|
Transform |
Block of XSLT text that is used to transform data.
|
TransformFile |
XSL File path that defines the transformation to be applied on XML file.
|
EnableCaching |
true/false. Whether to enable caching or not.
|
CacheDuration |
Number of seconds, data to be maintained in the cache.
|
CacheExpirationPolicy |
Absolute/Sliding. Cache policy to be applied on.
Absolute: The data is removed after specified duration. Sliding: The data is removed if it is not used for specified duration.
|
DEMO : ObjectDataSource
|
Show Source Code
|
|
For more on XML see XML Control
|
// TreeView Control ///////////////////////////////
<asp:TreeView ID="TreeView1" runat="server" DataSourceID="XmlDataSource1">
<DataBindings>
<asp:TreeNodeBinding TextField="#innertext" DataMember="Name" />
<asp:TreeNodeBinding TextField="#innertext" DataMember="From" />
</DataBindings>
</asp:TreeView>
// XmlDataSource Control ///////////////////////////////
<asp:XmlDataSource ID="XmlDataSource1" runat="Server" DataFile="~/tutorials/controls/controldata/XMLFile.xml"
XPath="DotNetFunda/Writers">
</asp:XmlDataSource>
// XML File ///////////////////////////////
<DotNetFunda>
<Writers>
<Name>Sheo Narayan</Name>
<From>Hyderabad, India</From>
</Writers>
<Writers>
<Name>Vijay Bandaru</Name>
<From>Virginia, USA</From>
</Writers>
<Writers>
<Name>Jay Shankar</Name>
<From>Aurangabad, India</From>
</Writers>
<Writers>
<Name>Dr. Sunita Narayan</Name>
<From>Bokaro, India</From>
</Writers>
<Writers>
<Name>Sunil Kumar Prasad</Name>
<From>Ranchi, India</From>
</Writers>
<Writers>
<Name>Sunita Shankar</Name>
<From>Daudnagar, India</From>
</Writers>
</DotNetFunda>
|