Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

ASP.NET XML Data Binding

ASP.NET Web Forms - XML File


We can bind an XML file to a list control.


An XML File

Here is an XML file named "countries.xml":

Norway

N

Sweden

S

France

F

Italy

I

View this XML file:countries.xml


Binding a DataSet to a List Control

First, import the "System.Data" namespace. We need this namespace to work with the DataSet object. Include the following directive at the top of the .aspx page:

<%@ Import Namespace="System.Data" %>

Next, create a DataSet for the XML file, and load the XML file into the DataSet when the page is first loaded:

AutoPostBack="True" onSelectedIndexChanged="displayMessage" />

Then we add a subroutine that is executed when the user clicks an item in the RadioButtonList control. When a radio button is clicked, a line of text appears in the label:

Example

<%@ Import Namespace="System.Data" %>

AutoPostBack="True" onSelectedIndexChanged="displayMessage" />

Demo Example »