Beginner Question About DropDown Lists

  • Thread starter Thread starter vbGansta
  • Start date Start date
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
 
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
 
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
 
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)
 
Back
Top