收藏此站 联系我们 网站
当前位置:首页» 行业新闻 » 【建站服务】喀什设计网页公司-域名申请

【建站服务】喀什设计网页公司-域名申请

作者: 风兰 . 阅读量: 5 . 发表时间:2022-09-21 05:55:56

网站建设
​

上往建站提供服务器空间服务商,百度快照排名,网站托管,百度推广运营,致力于设计外包服务与源代码定制开发,360推广,搜狗推广,增加网站的能见度及访问量提升网络营销的效果,主营:网站公司,百度推广公司电话,官网搭建服务,网站服务企业排名,服务器空间,英文域名等业务,专业团队服务,效果好。



喀什设计网页公司

网站建设.png

ASP.NET Web Forms - ArrayList 对象


ArrayList 对象是包含单个数据值的项目的集合。


实例

尝试一下 - 实例

ArrayList DropDownList

ArrayList RadioButtonList


创建 ArrayList

ArrayList 对象是包含单个数据值的项目的集合。

通过 Add() 方法向 ArrayList 添加项目。

下面的代码创建了一个名为 mycountries 的 ArrayList 对象,并添加了四个项目:

<script runat="server">
Sub Page_Load
if Not Page.IsPostBack then
dim mycountries=New ArrayList
mycountries.Add("Norway")
mycountries.Add("Sweden")
mycountries.Add("France")
mycountries.Add("Italy")
end if
end sub
</script>

在默认情况下,一个 ArrayList 对象包含 16 个条目。可通过 TrimToSize() 方法把 ArrayList 调整为最终尺寸:

<script runat="server">
Sub Page_Load
if Not Page.IsPostBack then
dim mycountries=New ArrayList
mycountries.Add("Norway")
mycountries.Add("Sweden")
mycountries.Add("France")
mycountries.Add("Italy")
mycountries.TrimToSize()
end if
end sub
</script>

通过 Sort() 方法,ArrayList 也能够按照字母顺序或者数字顺序进行排序:

<script runat="server">
Sub Page_Load
if Not Page.IsPostBack then
dim mycountries=New ArrayList
mycountries.Add("Norway")
mycountries.Add("Sweden")
mycountries.Add("France")
mycountries.Add("Italy")
mycountries.TrimToSize()
mycountries.Sort()
end if
end sub
</script>

要实现反向排序,请在 Sort() 方法后应用 Reverse() 方法:

<script runat="server">
Sub Page_Load
if Not Page.IsPostBack then
dim mycountries=New ArrayList
mycountries.Add("Norway")
mycountries.Add("Sweden")
mycountries.Add("France")
mycountries.Add("Italy")
mycountries.TrimToSize()
mycountries.Sort()
mycountries.Reverse()
end if
end sub
</script>



绑定数据到 ArrayList

ArrayList 对象可为下列的控件自动生成文本和值:

  • asp:RadioButtonList

  • asp:CheckBoxList

  • asp:DropDownList

  • asp:Listbox

为了绑定数据到 RadioButtonList 控件,首先要在 .aspx 页面中创建一个 RadioButtonList 控件(不带任何 asp:ListItem 元素):

<html>
<body>

<form runat="server">
<asp:RadioButtonList id="rb" runat="server" />
</form>

</body>
</html>

然后添加创建列表的脚本,并且绑定列表中的值到 RadioButtonList 控件:

实例

<script runat="server">
Sub Page_Load
if Not Page.IsPostBack then
dim mycountries=New ArrayList
mycountries.Add("Norway")
mycountries.Add("Sweden")
mycountries.Add("France")
mycountries.Add("Italy")
mycountries.TrimToSize()
mycountries.Sort()
rb.DataSource=mycountries
rb.DataBind()
end if
end sub
</script>

<html>
<body>

<form runat="server">
<asp:RadioButtonList id="rb" runat="server" />
</form>

</body>
</html>

演示实例 »

RadioButtonList 控件的 DataSource 属性被设置为该 ArrayList,它定义了这个 RadioButtonList 控件的数据源。RadioButtonList 控件的 DataBind() 方法把 RadioButtonList 控件与数据源绑定在一起。

注释:数据值作为控件的 Text 和 Value 属性来使用。如需添加不同于 Text 的 Value,请使用 Hashtable 对象或者 SortedList 对象。

ASP.NET Web Forms - Hashtable 对象

Hashtable 对象包含用键/值对表示的项目。


Examples

尝试一下 - 实例

Hashtable RadiobuttonList 1


Hashtable RadiobuttonList 2


Hashtable DropDownList


创建 Hashtable

Hashtable 对象包含用键/值对表示的项目。键被用作索引,通过搜索键,可以实现对值的快速搜索。


通过 Add() 方法向 Hashtable 添加项目。


下面的代码创建了一个名为 mycountries 的 Hashtable 对象,并添加了四个元素:


<script runat="server">

Sub Page_Load

if Not Page.IsPostBack then

dim mycountries=New Hashtable

mycountries.Add("N","Norway")

mycountries.Add("S","Sweden")

mycountries.Add("F","France")

mycountries.Add("I","Italy")

end if

end sub

</script>


数据绑定

Hashtable 对象可为下列的控件自动生成文本和值:


asp:RadioButtonList

asp:CheckBoxList

asp:DropDownList

asp:Listbox

为了绑定数据到 RadioButtonList 控件,首先要在 .aspx 页面中创建一个 RadioButtonList 控件(不带任何 asp:ListItem 元素):


<html>

<body>


<form runat="server">

<asp:RadioButtonList id="rb" runat="server" AutoPostBack="True" />

</form>


</body>

</html>

然后添加创建列表的脚本,并且绑定列表中的值到 RadioButtonList 控件:


<script runat="server">

sub Page_Load

if Not Page.IsPostBack then

dim mycountries=New Hashtable

mycountries.Add("N","Norway")

mycountries.Add("S","Sweden")

mycountries.Add("F","France")

mycountries.Add("I","Italy")

rb.DataSource=mycountries

rb.DataValueField="Key"

rb.DataTextField="Value"

rb.DataBind()

end if

end sub

</script>


<html>

<body>


<form runat="server">

<asp:RadioButtonList id="rb" runat="server" AutoPostBack="True" />

</form>


</body>

</html>

然后我们添加一个子例程,当用户点击 RadioButtonList 控件中的某个项目时,该子例程会被执行。当某个单选按钮被点击时,label 中会出现一行文本:


实例

<script runat="server">

sub Page_Load

if Not Page.IsPostBack then

dim mycountries=New Hashtable

mycountries.Add("N","Norway")

mycountries.Add("S","Sweden")

mycountries.Add("F","France")

mycountries.Add("I","Italy")

rb.DataSource=mycountries

rb.DataValueField="Key"

rb.DataTextField="Value"

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>


演示实例 »

注释:您无法选择添加到 Hashtable 的项目的排序方式。如需对项目进行字母排序或者数字排序,请使用 SortedList 对象。


喀什设计网页公司


上往建站提供搭建网站,域名注册,官网备案服务,网店详情页设计,企业网店,专业网络店铺管理运营全托管公司咨询电话,服务器空间,微信公众号托管,网页美工排版,致力于域名申请,竞价托管,软文推广,全网营销,提供标准级专业技术保障,了却后顾之忧,主营:虚拟主机,网站推广,百度竞价托管,网站建设,上网建站推广服务,网络公司有哪些等业务,专业团队服务,效果好。

服务热线:400-111-6878 手机微信同号:18118153152(各城市商务人员可上门服务)


关键词:网站建设,企业网站,网站制作,网页设计,高端网站建设,企业网站制作,网页制作,制作网站,网站设计,高端网页设计,高端网站设计,做网站,自适应网站

全国服务热线
18114747181
二维码
手机端二维码
上往建站
地址:全国各地都有驻点商务 |  网站建设:上往建站
在线咨询QQ:1120768800
 
QQ在线咨询
售前咨询热线
18114747181
营销顾问
营销顾问
售后服务热线
400-000-1116
售后服务
售后服务