How To Fill DropDownList Control With ArrayList?
You can fill DropDownList control with items of ArrayList control by using its DataSource property. One of solutions is code like this:
[ C# ]
//
Create ArrayList alColors and populate it
// with
some items
ArrayList alColors =
new ArrayList();
alColors.Add("Red");
alColors.Add("Green");
alColors.Add("Yellow");
alColors.Add("Blue");
// Show
ArrayList items in DropDownList named ddlColors
ddlColors.DataSource =
alColors;
ddlColors.DataBind();
[ VB.NET ]
' Create
ArrayList alColors and populate it
' with
some items
Dim
alColors As ArrayList =
New ArrayList()
alColors.Add("Red")
alColors.Add("Green")
alColors.Add("Yellow")
alColors.Add("Blue")
' Show
ArrayList items in DropDownList named ddlColors
ddlColors.DataSource =
alColors
ddlColors.DataBind()
Related articles:
1. Export Crystal Reports to PDF file