XmlDataSource.DataFile Property


The .NET API Reference documentation has a new home. Visit the .NET API Browser on docs.microsoft.com to see the new experience.

Specifies the file name of an XML file that the data source binds to.

Namespace:   System.Web.UI.WebControls
Assembly:  System.Web (in System.Web.dll)

abstract DataFile : string with get, set
override DataFile : string with get, set

Property Value

Type: System.String

The 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

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.

No code example is currently available or this language may not be supported.

The XML file in the code example has the following data:

     <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"/>                
     <book title="Silicon Valley Gastronomic Treats" author="Innes del Castill"/>

.NET Framework
Available since 2.0
Return to top