XmlDataSource
XmlDataSource Control is a DataToolBox Control. Here i present a simple example of XmlDataSource Control.
StandardToolBoxControls.xml
First create a Xml file name StandardToolBoxControls.xml. Here is the source code of StandardToolBoxControls.xml file.
<?xml version="1.0" encoding="utf-8" ?>
<StandardToolBox>
<Control Name="AdRotator" />
<Control Name="BulletedList" />
<Control Name="Button" />
<Control Name="Calendar" />
<Control Name="CheckBox" />
<Control Name="CheckBoxList" />
<Control Name="DropDownList" />
<Control Name="FileUpload" />
<Control Name="HiddenField" />
<Control Name="HyperLink" />
<Control Name="Image" />
<Control Name="ImageMap" />
<Control Name="ListBox" />
<Control Name="Literal" />
<Control Name="Localize" />
<Control Name="MultiView" />
<Control Name="View" />
<Control Name="Panel" />
<Control Name="PlaceHolder" />
<Control Name="RadioButton" />
<Control Name="RadioButtonList" />
<Control Name="Substitution" />
<Control Name="Table" />
<Control Name="TextBox" />
<Control Name="Wizard" />
<Control Name="XML" />
</StandardToolBox>
Populate RadioButtonList with XmlDataSource
Now create a Web Form name XmlDataSource.aspx. Then place an XmlDataSource control and a RadioButtonList control. Here we populate the RadioButtonList control with XmlDataSource control. When someone selects a option then it shows in label control. The source code of XmlDataSource.aspx file is below.
<%@ Page Language="C#" %>
<!DOCTYPE html>
<script runat="server">
protected void RadioButtonList1_SelectedIndexChanged(object sender, System.EventArgs e) {
Label1.Text ="Your favorite control: "+ RadioButtonList1.SelectedItem.Text.ToString();
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>XmlDataSource Simple Example</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:XmlDataSource ID="XmlDataSource1" runat="server"
DataFile="~/App_Data/StandardToolBoxControls.xml">
</asp:XmlDataSource>
<asp:Label ID="Label1" runat="server" Font-Size="Medium" ForeColor="Fuchsia">
</asp:Label>
<br /><br />
<asp:Label ID="Label2" runat="server" Text="Select your most favorite Standard ToolBox Control" Font-Size="Large" ForeColor="DarkRed">
</asp:Label>
<asp:RadioButtonList
ID="RadioButtonList1"
runat="server"
DataSourceID="XmlDataSource1"
DataMember="Control"
DataTextField="Name"
RepeatColumns="4"
AutoPostBack="true"
OnSelectedIndexChanged="RadioButtonList1_SelectedIndexChanged"
>
</asp:RadioButtonList>
</div>
</form>
</body>
</html>

