我們可以結合一個XML檔案到清單控制
範例
例如1 -X ML的R adiobuttonList
一個XML檔案
這是一個XML檔案名稱為“ countries.xml ” :
<?xml version="1.0" encoding="ISO-8859-1"?>
<countries>
<country>
<text>Norway</text>
<value>N</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>
看看XML檔案: countries.xml -------------------------------------------------- ------------------------------ 一個DataSet綁定到控制列表首先,進口的“ System.Data ”命名空間。我們需要這種命名與DataSet對象。包括下列指令上方的一個。 aspx頁:<%@ Import Namespace="System.Data" %>下一步,建立一個DataSet的XML檔案,並載入XML檔案到DataSet網頁時首先載入:<script runat="server">
sub Page_Load
if Not Page.IsPostBack then
dim mycountries=New DataSet
mycountries.ReadXml(MapPath("countries.xml"))
end if
end sub綁定資料到RadioButtonList控制項,首先建立一個RadioButtonList控制項(無任何ASP : ListItem元素)的。aspx頁:html>
<body><form runat="server">
<asp:RadioButtonList id="rb" runat="server"
AutoPostBack="True" /></form></body>
</html>Then add the script