Skip Navigation LinksASP.Net 2.0 Training : ASP.Net Lists
Banner for ASP.Net 2.0 training classes in Visual Basic 2005 

Skip Navigation Links
Visit my other site:

certification training

Free Flash tutorials and training

Free Dreamweaver Video Tutorials

Free PHP Training

Visual Basic Windows Training




If you like this site please link to it


Lists

ArrayList-A collection of items containing a single data value.
Use the Add method to add items to the ArrayList

Example:

1 <script runat="server">
2    Sub Page_Load
3       if Not Page.IsPostBack then
4          dim Munsters=New ArrayList
5           Munsters.Add("Herman")
6          Munsters.Add("Lily")
7          Munsters.Add("Grandpa")
8          Munsters.Add("Eddie")
9          Munsters.Add("Marylyn")
10       end if
11    end sub
12 </script>

An ArrayList object contains 16 entries by default.
You can resize an ArrayList with the TrimToSize() method:

Example:

1 <script runat="server">
2    Sub Page_Load
3       if Not Page.IsPostBack then
4          dim Munsters=New ArrayList
5           Munsters.Add("Herman")
6          Munsters.Add("Lily")
7          Munsters.Add("Grandpa")
8          Munsters.Add("Eddie")
9          Munsters.Add("Marylyn")
10          Munsters.TrimToSize()
11       end if
12    end sub
13 </script>

You can sort an ArrayList alphabetically or numerically with Sort()

Example:

1 <script runat="server">
2    Sub Page_Load
3       if Not Page.IsPostBack then
4          dim Munsters=New ArrayList
5           Munsters.Add("Herman")
6          Munsters.Add("Lily")
7          Munsters.Add("Grandpa")
8          Munsters.Add("Eddie")
9          Munsters.Add("Marylyn")
10          Munsters.TrimToSize()
11          Munsters.Sort()
12       end if
13    end sub
14 </script>

You can sort in reverse order using Reverse() after the Sort() method

Example:

1 <script runat="server">
2    Sub Page_Load
3       if Not Page.IsPostBack then
4          dim Munsters=New ArrayList
5           Munsters.Add("Herman")
6          Munsters.Add("Lily")
7          Munsters.Add("Grandpa")
8          Munsters.Add("Eddie")
9          Munsters.Add("Marylyn")
10          Munsters.TrimToSize()
11          Munsters.Sort()
12          Munsters.Reverse()
13       end if
14    end sub
15 </script>

List Controls

3 types

  1. Simple List Controls
    1. CheckboxList
    2. DropDownList
    3. Listbox
    4. RadioButtonList
  2. RepeaterControl
    1. Repeater
  3. ComplexListControls
    1. DataList
    2. DataGrid

Common Properties of List Controls

Property

Description

AutoPostBack

Postback occurs then user changes list selection

DataMember

Table

DataSource

dataSource

DataTextField

Field in the dataSource to use

DataTextFormatString

Formatting string that controls the format of the data

DataValueField

What field in the data source provides the value of each list item

Items

Collection of items in the list control

SelectedIndex

Lowest index of the selected items

SelectedItem

Item selected with the lowest index in the list control

Events:

OnSelectedIndexChanged

Called whenever the selection of the list control changes and is posted back to the server.


      ASP.Net 2.0 tutorials & training