Select value for Data Binding to an ArrayList

  • Thread starter Thread starter Steven K
  • Start date Start date
S

Steven K

Hello,

I am creating the following ArrayList to bind to a DropDownList
(ddlYearBox).

ctrFor = 0
Dim arrFor as ArrayList = new ArrayList()
For ctrFor = 2002 To 2020
arrFor.Add (ctrFor)
Next

ddlYearBox.DataSource = arrFor
ddlYearBox.DataBind


The text and values are equal to ctrFor, but can you add the "Selected"
value using an ArrayList?
 
The text and values are equal to ctrFor, but can you add the "Selected" value using an ArrayList

Not sure I understand you but I think you mean setting the selected property of the DropDownList item?

To set the selected property you can use
ddlYearBox.Items.FindByValue("2002").Selected = True 'You should check the FindByValue method returns a ListIte

Suresh

----- Steven K wrote: ----

Hello

I am creating the following ArrayList to bind to a DropDownLis
(ddlYearBox)

ctrFor =
Dim arrFor as ArrayList = new ArrayList(
For ctrFor = 2002 To 202
arrFor.Add (ctrFor
Nex

ddlYearBox.DataSource = arrFo
ddlYearBox.DataBin


The text and values are equal to ctrFor, but can you add the "Selected
value using an ArrayList
 
Back
Top