ASP.NET DataTextField 属性
ASP.NET DataTextField 属性
ListControl 控件参考手册
定义和用法
DataTextField 属性规定要绑定到控件中每个项目的 Text 属性的数据源字段。
实例
下面的实例使用一个 XML 文件来填充 RadioButtonList 的数据:
<%@ 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="You selected: " & rb.SelectedItem.Text
end sub
</script>
<form runat="server">
<asp:RadioButtonList id="rb" AutoPostBack="True"
runat="server" onSelectedIndexChanged="displayMessage" />
<asp:label id="lbl1" runat="server" />
</form>
<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="You selected: " & rb.SelectedItem.Text
end sub
</script>
<form runat="server">
<asp:RadioButtonList id="rb" AutoPostBack="True"
runat="server" onSelectedIndexChanged="displayMessage" />
<asp:label id="lbl1" runat="server" />
</form>
演示实例 »
实例中使用的 XML 文件是 countries.xml
ListControl 控件参考手册