DropDownList 控件 DataTextField 和 DataValueField 分开绑定

王朝asp·作者佚名  2006-01-09
窄屏简体版  字體: |||超大  

<SCRIPT runat="server">

Sub Page_Load

If Not Page.IsPostBack Then

Dim URLs = New SortedList()

URLs.Add("Google", "http://www.google.com")

URLs.Add("MSN", "http://search.msn.com")

URLs.Add("Yahoo", "http://www.yahoo.com")

URLs.Add("Lycos", "http://www.lycos.com")

URLs.Add("AltaVista", "http://www.altavista.com")

URLs.Add("Excite", "http://www.excite.com")

'-- Bind SortedList to controls

RadioButtons.DataSource = URLs

RadioButtons.DataTextField = "Key"

RadioButtons.DataValueField = "Value"

RadioButtons.DataBind()

CheckBoxes.DataSource = URLs

CheckBoxes.DataTextField = "Key"

CheckBoxes.DataValueField = "Value"

CheckBoxes.DataBind()

DropDownList.DataSource = URLs

DropDownList.DataTextField = "Key"

DropDownList.DataValueField = "Value"

DropDownList.DataBind()

ListBox.DataSource = URLs

ListBox.DataTextField = "Key"

ListBox.DataValueField = "Value"

ListBox.DataBind()

End If

End Sub

</SCRIPT>

原网站 http://it.maconstate.edu/tutorials/ASPNET/ASPNET07/aspnet07-03.aspx

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
 
 
© 2005- 王朝網路 版權所有 導航