Beginner Question About DropDown Lists

V

vbGansta

Hi there,

I just started programming with .net a few weeks ago. I have a webform that
has a few controls on it. I would like the user to be able to select a
month from the first drop down and after they do this my second dropdown
would be populated with the correct number of days. I.E. The user selects
January in Dropdown 1 and then DropDown2 gets populated with items 1.....31.

Thanks for your help

Joe
 
T

Troy Simpson

Hi Joe,

Set AutoPostBack to True for your dropdownlist. In the Form_Load, or
somewhere, put in the code :

AddHandler dlMyDropDownList.SelectedIndexChanged, AddressOf
dlMyDropDownListChanged

Then make a handler for the changed event :

Private Sub dlAddPositionChanged(ByVal sender As Object, ByVal e As
System.EventArgs)
dlMyOtherDropDownList.SelectedValue = value based on
sender.SelectedValue
End Sub
 
V

vbGansta

Thanks very much Troy that worked great.

Joe
Troy Simpson said:
Hi Joe,

Set AutoPostBack to True for your dropdownlist. In the Form_Load, or
somewhere, put in the code :

AddHandler dlMyDropDownList.SelectedIndexChanged, AddressOf
dlMyDropDownListChanged

Then make a handler for the changed event :

Private Sub dlAddPositionChanged(ByVal sender As Object, ByVal e As
System.EventArgs)
dlMyOtherDropDownList.SelectedValue = value based on
sender.SelectedValue
End Sub
 
T

Troy Simpson

Set AutoPostBack to True for your dropdownlist. In the Form_Load, or
somewhere, put in the code :

AddHandler dlMyDropDownList.SelectedIndexChanged, AddressOf
dlMyDropDownListChanged

Then make a handler for the changed event :

Private Sub dlAddPositionChanged(ByVal sender As Object, ByVal e As
System.EventArgs)

Oops,

The handler declaration should have been :

Private Sub dlMyDropDownListChanged(ByVal sender As Object, ByVal e As
System.EventArgs)
 

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

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top