By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,836 Members | 1,983 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,836 IT Pros & Developers. It's quick & easy.

Populate Drop Down List

P: n/a
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.
Nov 20 '05 #1
Share this Question
Share on Google+
7 Replies


P: n/a
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

"Miguel Dias Moura" <we****@27NOSPAMlamps.com> wrote in message
news:eW**************@TK2MSFTNGP12.phx.gbl...
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.

Nov 20 '05 #2

P: n/a
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


"Miguel Dias Moura" <we****@27NOSPAMlamps.com> wrote in message
news:eW**************@TK2MSFTNGP12.phx.gbl...
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.

Nov 20 '05 #3

P: n/a
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
Nov 20 '05 #4

P: n/a
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

"Cor Ligthert" <no**********@planet.nl> wrote in message
news:#t**************@TK2MSFTNGP10.phx.gbl...
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

Nov 20 '05 #5

P: n/a
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
Nov 20 '05 #6

P: n/a
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
"Cor Ligthert" <no**********@planet.nl> wrote in message
news:eE**************@TK2MSFTNGP11.phx.gbl...
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

Nov 20 '05 #7

P: n/a
Hi Miguel,

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

Cor

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.

Nov 20 '05 #8

This discussion thread is closed

Replies have been disabled for this discussion.