[ppt制作入门教程]net入门教程:ASP.NET ArrayList 对象

时间:2015-08-12  来源:基础入门  阅读:

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页:




然后添加脚本,建立名单,并结合中的值列表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>



该DataSource属性的RadioButtonList控件设置为ArrayList的,它定义了数据源的RadioButtonList控件。的DataBind ( )方法RadioButtonList控件绑定的数据源与RadioButtonList控件。 注:数据值被用来作为两种文字和Value属性的控制。若要新增价值观念不同的文字,可以使用哈希表对象或SortedList对象。

[ppt制作入门教程]net入门教程:ASP.NET ArrayList 对象

http://m.bbyears.com/asp/17230.html

推荐访问:excel基础入门教程 弹吉他入门教程
相关阅读 猜你喜欢
本类排行 本类最新