Configure Data Source Dialog Box - XmlDataSource

The Configure Data Source - XmlDataSource dialog box helps you to configure an XML data source when you want to display XML data in an ASP.NET Web server control that supports data binding. The title of the dialog box changes according to the ID of the data source control.

You can use an XML data source to display both hierarchical and tabular data, although it is typically used to display hierarchical XML data in read-only scenarios.

Security noteSecurity Note

If you are storing data in an XML file, you should place the XML file in your Web site's App_Data folder because the contents of the folder will not be returned to direct HTTP requests. For more information, see Securing Data Access.

Web server controls that support data binding include, but are not limited to, the following:

BulletedList

DetailsView

GridView

RadioButtonList

CheckBoxList

DropDownList

ListBox

Repeater

DataList

FormView

Menu

TreeView

To access this dialog box from an ASP.NET Web server control

  1. In Visual Web Developer, open an ASPX page.

  2. Switch to Design view.

  3. From the Toolbox, drag one of the controls from the previous list onto the page. For example, from the Standard group of the Toolbox, drag a ListBox control onto the page.

  4. Right-click the control and click Show Smart Tag.

  5. In the tasks window that appears, from the Choose Data Source drop-down list, select <New data source…>.

    Note

    Some controls only allow you to click Choose Data Source, after which you select <New data source…> from the Select a data source drop-down list.

    The Data Source Configuration Wizard opens.

  6. Under Where will the application get data from, click XML File.

  7. In the Specify an ID for the data source box, type a data source ID.

    The default ID is XmlDataSource1.

  8. Click OK.

    An XmlDataSource control is automatically created on your page, and the Configure Data Source - XmlDataSource1 window opens.

To access this dialog box directly from an XmlDataSource control

  1. In Visual Web Developer, open an ASPX page.

  2. Switch to Design view.

  3. From the Data group of the Toolbox, drag an XmlDataSource control onto the page.

  4. In the tasks window, click Configure Data Source.

    The Configure Data Source - XmlDataSource1 window opens.

    After you configure the XmlDataSource control, you can bind it to any of the Web server controls in the list above by specifying the data source ID in the Choose Data Source drop-down list, or in the DataSourceID property of the Web server control.

For more information about data binding, see ASP.NET Data Access Overview, or the following task-oriented topics.

Tasks

Walkthrough: Creating a Web Page to Display XML Data

Walkthrough: Displaying Hierarchical Data in a TreeView Control

How to: Bind to Data in a Templated Control in Visual Studio

How To: Secure Connection Strings when Using Data Source Controls

How to: Bind to Data in a Templated Control

UI Elements

  • Data file
    Specifies the relative path to an XML data file to use as the source for this control. If you store your XML file in the App_Data folder, then the format of the relative path would be similar to the following:

    ~/App_Data/exampleXmlDataFile.xml

  • Transform file
    Specifies the relative path to an optional transform file that describes how the structure of the XML file should be converted to a different structure. If you store your XML file in the App_Data folder, then the format of the relative path would be similar to the following:

    ~/App_Data/exampleTransformFile.xml

  • XPath expression
    Specifies an optional XPath expression that allows you to filter the data in the XML file to return a subset of the file. An XPath uses the following format, where any number of child element levels can be specified:

    /rootElementName/childElementName

    If an XPath expression is specified, only the data at the level of the specified element and below is returned.

See Also

Reference

XmlDataSource

Concepts

ASP.NET Data-Bound Web Server Controls Overview

Data Source Controls Overview

Securing Data Access

XmlDataSource Web Server Control Overview

Filtering Data Using the XmlDataSource Control

Binding a Tabular Control to the XmlDataSource Control

Binding to Data Using a Data Source Control

Binding Data to the TreeView Web Server Control

Binding to Hierarchical Data

Data-Binding Expressions Overview