XmlDataSource::DataFile Property
Specifies the file name of an XML file that the data source binds to.
Assembly: System.Web (in System.Web.dll)
public: virtual property String^ DataFile { String^ get (); void set (String^ value); }
<asp:XmlDataSource DataFile="String" />
Property Value
Type: System::StringThe absolute physical path or relative path of the XML file that contains data that the XmlDataSource control represents. The default value is String::Empty.
| Exception | Condition |
|---|---|
| InvalidOperationException | The document is loading. |
If both the DataFile and Data properties are set, the DataFile property takes precedence and the data in the XML file is used instead of the XML data specified in the Data property.
If you change the value of the DataFile property, the DataSourceChanged event is raised. If caching is enabled and you change the value of DataFile, the cache is invalidated.
The following code example demonstrates how to use an XmlDataSource control to display XML data contained in a file with a TreeView control.
The XML file in the code example has the following data:
<books>
<computerbooks>
<book title="Secrets of Silicon Valley" author="Sheryl Hunter"/>
<book title="Straight Talk About Computers" author="Dean Straight"/>
<book title="You Can Combat Computer Stress!" author="Marjorie Green"/>
</computerbooks>
<cookbooks>
<book title="Silicon Valley Gastronomic Treats" author="Innes del Castill"/>
</cookbooks>
</books>
Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98
The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.