当前位置:编程学习 > asp >>

DropDownList 控件 DataTextField 和 DataValueField 分开绑定

答案:<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>

上一个:将ASP的Debug变得简单的两个函数!
下一个:ASP 调用 ORACLE存储过程并返回结果集

CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,