教程集 www.jiaochengji.com
教程集 >  脚本编程  >  Asp.net  >  正文 net入门教程:ASP.NET ArrayList 对象

net入门教程:ASP.NET ArrayList 对象

发布时间:2018-10-02   编辑:jiaochengji.com
教程集为您提供net入门教程:ASP.NET ArrayList 对象等资源,欢迎您收藏本站,我们将为您提供最新的net入门教程:ASP.NET ArrayList 对象资源

ASP.NET ArrayList 对象

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

创建一个ArrayList
ArrayList的对象是一个收集的项目包含一个单一的数据值。

项目被添加到该ArrayList与购买( )方法。

下面的代码创建一个新的ArrayList对象命名mycountries和4个项目是补充说:

<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个条目。一个ArrayList可以中小型其最终规模与TrimToSize ( )方法:

<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>
一个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>排序顺序相反,适用于逆向( )方法后,排序( )方法:<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对象可以自动生成的文字和价值观下列管制: 动态: RadioButtonList 动态: CheckBoxList 动态:下拉列表动态:列表框绑定数据到RadioButtonList控件,首先创建一个RadioButtonList控件(无任何ASP : ListItem元素)的。 aspx页:<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>该DataSource属性的RadioButtonList控件设置为ArrayList的,它定义了数据源的RadioButtonList控件。的DataBind ( )方法RadioButtonList控件绑定的数据源与RadioButtonList控件。 注:数据值被用来作为两种文字和Value属性的控制。若要新增价值观念不同的文字,可以使用哈希表对象或SortedList对象。

您可能感兴趣的文章:
net入门教程:ASP.NET ArrayList 对象
深入浅出asp.NET泛型编程.NET泛型编程入门教程
net和php哪个好学
net 教程:ASP.NET SortedList 对象
ASP.NET 入门的五个步骤
asp.net入门教程:ASP.NET SortedList 对象教程
IList与ArrayList简单实现与区别
java删除ArrayList中重复的元素
asp.net ArrayList用法
C# 泛型集合List与非泛型集合ArrayList之性能比较

[关闭]
~ ~