Friday, March 16, 2012

Populating dropdown on server side...(non database)

This is probably really simple but I have a mental block on this...
I want to populate a dropdown on the serverside thru code and am unsure of which methods or properties to use...
Its a simple dropdown. Numbered 1 to 100. So I know I have to loop thru..
Any help would be appreciated...What kind of data source you what to use to populate the DDL if not from database?
You will need to create an array, add data to that array and Bind it to your list:


Dim month as New ArrayList

'adding values for array month
With month
.Add("Jan")
.Add("Feb")
.Add("Mar")
.Add("Apr")
.Add("May")
.Add("Jun")
.Add("Jul")
.Add("Aug")
.Add("Sep")
.Add("Oct")
.Add("Nov")
.Add("Dec")
End With

'bind it to your drop down list

DDList.DataSource=month
DDList.DataBind()


Just a loop...sort of like this
I am just not sure what mehods to use...
dim x as integer
Do while x <= 100
dropdown1.add = x
x = x+1
loop
 Dim month as New ArrayList

dim x as integer

Do while x <= 100

with month
.add = x
end with

x = x+1

loop

DDList.DataSource=month

DDList.DataBind()

0 comments:

Post a Comment