Populate Drop Down List

M

Miguel Dias Moura

Hello,

i have an ASP.NET / VB page where i have a few 4 groups of Drop Down Lists.
Each group of Drop Down Lists include 3 Drop Down Lists for date such as:
DAY, MONTH, and YEAR.

I don't want to insert the values and text to each drop down list.

So i want to create a script that populates a certain Drop Down List with
certain values when page loads such as:

Day: 1,2,3,4,5,...
Month: January, February, ..., December
Year: 2004, 2003, 2002, 2001, ....

This way in that script i will be able to control how all the Drop Down
Lists are populated just bu changing the script.

Can you help me out?

Thank You,
Miguel

P.S: I am working with ASP.NET / VB.
 
O

One Handed Man \( OHM#\)

It's not clear how these are supposed to relate, in other words, do you want
the DAYS DDL to be dependent on the year and month chosen, if so you need to
turn on AutoPostback for those controls and then populate the DAYS
accordingly

ANYHOOO

Create a DataSet and In it Create Tables containing the DataRows, then bind
the DataSource and Display Member of the Dropdown's to the DataSet.DataTable

OR

Create an Array for each and set the bindings for the DropDown to the
Arrays containing it


Cheers - OHM
 
S

SStory

Hola Miguel,

Mejor preguntarles en el grupo asp.net.

Pero
porque no solo haga algo asi...

miDropDown.items.Add()

Creo que funciona. Se que funciona en vb.net

En ASP.net no recuedo sin buscar.

Espero que te ayuda.

Shane
 
C

Cor Ligthert

Hi Miguel,

I did send you a sample about this 2 weeks ago in this newsgroup for almost
the same question from you, however no reaction.

It was a little bit else, however bassicly the same, I thought I changed it
now again exactly as you said. But maybe you have a totally different
meaning with your question.

I think it is better if you give a reaction if the sample does not fits your
needs.

I hope this helps?

Cor

\\\
Private Sub Page_Load1(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
Me.DropDownList1.Items.Clear()
Me.DropDownList2.Items.Clear()
Me.DropDownList3.Items.Clear()
For i As Integer = 1 To 31
Dim a As New ListItem
Me.DropDownList1.Items.Add(a)
Me.DropDownList1.Items(i - 1).Text = i.ToString
Me.DropDownList1.Items(i - 1).Value = i.ToString
Next
For i As Integer = 1 To 12
Dim a As New ListItem
Me.DropDownList2.Items.Add(a)
Me.DropDownList2.Items(i - 1).Text = _
CDate("01/" & i.ToString & "/1900").ToString("MMMM")
Me.DropDownList2.Items(i - 1).Value = _
CDate("01/" & i.ToString & "/1900").ToString("MMMM")
Next
For i As Integer = 0 To 100
Dim a As New ListItem
Me.DropDownList3.Items.Add(a)
Me.DropDownList3.Items(i).Text = (2004 - i).ToString
Me.DropDownList3.Items(i).Value = (2004 - i).ToString
Next
End Sub
 
M

Miguel Dias Moura

Hello,

you are right, i had a similar question posted 2 weeks ago but i didn't mark
it and somehow i haven't been able to find it in my Outlook Express list.

About your code, i just tryied it but i got an error:
BC30529: All parameters must be explicitly typed if any are.
Line 6: Private Sub Page_Load1(ByVal sender As Object, _ByVal e As
System.EventArgs) Handles formSubscribe.Load

I allways had problems with the Page_Load and i have no idea what is going
on?

Could you tell me what am i doing wrong or even send me a sample file of
this working so i can look at it (you can send it to my email - just take
the NOSPAM).

Thank You,
Miguel
 
C

Cor Ligthert

Hi Miguel,

Only in extreem situations most regulars in this newsgroup take mail.
However why do you not show some code around that line 6?

Now we are working in the blind.

Cor
 
M

Miguel Dias Moura

Hi,

i wrote line 6:

"Line 6: Private Sub Page_Load1(ByVal sender As Object, _ByVal e As
System.EventArgs) Handles formSubscribe.Load"

I only used the code you indicated me. I didn't make any change to it.

Thank You,
Miguel
 
C

Cor Ligthert

Hi Miguel,

I wrote around this line, for me that means as well some before and some
behindl, (after the section I sand).

Cor
 

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