Select value for Data Binding to an ArrayList

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?
 
G

Guest

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top