Countries. xml
<? XML version = "1.0" encoding = "ISO-8859-1"?>
<Countries>
<Country>
<Text> China </text>
<Value> C </value>
</Country>
<Country>
<Text> Sweden </text>
<Value> S </value>
</Country>
<Country>
<Text> France </text>
<Value> F </value>
</Country>
<Country>
<Text> Italy </text>
<Value> I </value>
</Country>
</Countries>
Bind dataset to the list control catalog -------------------------------------------------------------------------------------
First, import the "system. Data" namespace. We need the namespace to work with the DataSet object. Include the following command at the top of the. ASPX page.
Load the XML file into dataset when the page is first loaded.
Create a radiobuttonlist control on the. ASPX page (without any ASP: listitem element ).
Add a subroutine that is executed when you click the project in the radiobuttonlist control. When you click a single-choice button, a text will appear in the label.
<% @ Import namespace = "system. Data" %>
<SCRIPT runat = "server">
Sub page_load
If not page. ispostback then
Dim mycountries = new dataset
Mycountries. readxml (mappath ("countries. xml "))
RB. datasource = mycountries
RB. datavaluefield = "value"
RB. datatextfield = "text"
RB. databind ()
End if
End sub
sub displayMessage(s as Object,e As EventArgs)
lbl1.text="Your favorite country is: " & rb.SelectedItem.Text
end sub
</SCRIPT>
<HTML>
<Body>
<Form runat = "server">
<Asp: radiobuttonlist id = "rb" runat = "server"
Autopostback = "true" onselectedindexchanged = "displaymessage"/>
<P> <asp: Label id = "lbl1" runat = "server"/> </P>
</Form>
</Body>
</Html>