473,836 Members | 1,379 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Populate Drop Down List

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
7 6315
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.DataTab le

OR

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

"Miguel Dias Moura" <we****@27NOSPA Mlamps.com> wrote in message
news:eW******** ******@TK2MSFTN GP12.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
Hola Miguel,

Mejor preguntarles en el grupo asp.net.

Pero
porque no solo haga algo asi...

miDropDown.item s.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****@27NOSPA Mlamps.com> wrote in message
news:eW******** ******@TK2MSFTN GP12.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
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(ByVa l sender As Object, _
ByVal e As System.EventArg s) Handles MyBase.Load
Me.DropDownList 1.Items.Clear()
Me.DropDownList 2.Items.Clear()
Me.DropDownList 3.Items.Clear()
For i As Integer = 1 To 31
Dim a As New ListItem
Me.DropDownList 1.Items.Add(a)
Me.DropDownList 1.Items(i - 1).Text = i.ToString
Me.DropDownList 1.Items(i - 1).Value = i.ToString
Next
For i As Integer = 1 To 12
Dim a As New ListItem
Me.DropDownList 2.Items.Add(a)
Me.DropDownList 2.Items(i - 1).Text = _
CDate("01/" & i.ToString & "/1900").ToString ("MMMM")
Me.DropDownList 2.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.DropDownList 3.Items.Add(a)
Me.DropDownList 3.Items(i).Text = (2004 - i).ToString
Me.DropDownList 3.Items(i).Valu e = (2004 - i).ToString
Next
End Sub
Nov 20 '05 #4
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(ByVa l sender As Object, _ByVal e As
System.EventArg s) Handles formSubscribe.L oad

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**********@p lanet.nl> wrote in message
news:#t******** ******@TK2MSFTN GP10.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(ByVa l sender As Object, _
ByVal e As System.EventArg s) Handles MyBase.Load
Me.DropDownList 1.Items.Clear()
Me.DropDownList 2.Items.Clear()
Me.DropDownList 3.Items.Clear()
For i As Integer = 1 To 31
Dim a As New ListItem
Me.DropDownList 1.Items.Add(a)
Me.DropDownList 1.Items(i - 1).Text = i.ToString
Me.DropDownList 1.Items(i - 1).Value = i.ToString
Next
For i As Integer = 1 To 12
Dim a As New ListItem
Me.DropDownList 2.Items.Add(a)
Me.DropDownList 2.Items(i - 1).Text = _
CDate("01/" & i.ToString & "/1900").ToString ("MMMM")
Me.DropDownList 2.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.DropDownList 3.Items.Add(a)
Me.DropDownList 3.Items(i).Text = (2004 - i).ToString
Me.DropDownList 3.Items(i).Valu e = (2004 - i).ToString
Next
End Sub

Nov 20 '05 #5
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
Hi,

i wrote line 6:

"Line 6: Private Sub Page_Load1(ByVa l sender As Object, _ByVal e As
System.EventArg s) Handles formSubscribe.L oad"

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

Thank You,
Miguel
"Cor Ligthert" <no**********@p lanet.nl> wrote in message
news:eE******** ******@TK2MSFTN GP11.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
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(ByVa l sender As Object, _ByVal e As
System.EventArg s) Handles formSubscribe.L oad"

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

Nov 20 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
11240
by: julian | last post by:
hi I was wondering if anyone can help me out on this.... I have dynamcally populated a drop down menu with data from an access database using ASP. The values seem fine, however when i pass them to the next page (using form get method) the whitespaces in the values are ignored. For example with <option value=jim jones> then only "jim" gets passed to the next page not "jim jones". I have viewed the source created on the dynamic page and...
3
14226
by: Miguel Dias Moura | last post by:
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:
1
2493
by: msnews.microsoft.com | last post by:
I'd like to hear your thoughts on best methods for populating drop down list controls. I have states and countries drop down lists that don't change often, so naturally I "hard code" them in the aspx page. But the problem is these tend to really slow the development -- it takes up to 15 seconds for the page to come up in VS.NET design environment, so I'm thinking about taking these out and populating the controls dynamically using the...
1
2053
by: csgraham74 | last post by:
Hi Guys, I am currently building a web aplication in ASP.Net. On the onload event of a page a have a function to populate the many drop down lists on my page. I have one parameter table which stores all the values e.g. Title,Type,Status,Property,Occupation. I am using a sql string and then populationg my drop down list
1
296
by: puja | last post by:
hi all, I have a requirement where I need to populate drop down list (which is not run at server control. i.e it is an html control ) using server side code in C#? How can I add option values to drop down list in page load event. Thanks puja
2
1925
by: tom c | last post by:
I have a dropdown list box on an ASP.Net 1.1 webform. I populate it from a dataset in code. Everything looks fine and I can see all the values in the dropdownlist. I can select a value and I see that new selected value in the list box. However, when I look for the values in code, I see the original value from the list box. The one that was loaded first and showed up before I selected a new one. This is the code I use to look at the...
3
6901
by: Yi Chen | last post by:
We have a drop down list on a PHP page, with several product names, and when people click one item, we will refresh the same page with the product name as parameter, and in turn we want to include a HTML file into the content area of the same page. I know it is recommended to put everything into database, but we want the web site to be very "portable", so the drop-downlist and the content should both in text files. Let's say the...
3
7363
by: penny111 | last post by:
Hi there, For my application, i need to have 3 drop down lists 1. drop down list of folder names 2. drop down list of documents in the folder selected 3. drop down list of instances of the document selected (my application uses the BusinessObjects Java Web Services SDK) The 2nd list is dependent on the 1st, while the 3rd list is dependent on the 2nd. In other words, this is what i want my application to do -select a folder from the...
3
2329
by: DaveRook | last post by:
Hi I am using C# and Access databse for a web site. I have a drop down list which I need to populate dynamically according to results in a database. Example There will be 1 drop down list on the page which offers 3 makes of cars: Mazda, Honda, Ford
0
9825
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9672
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
10601
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10260
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7794
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6981
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5652
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5829
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4460
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.