joe_pool_is
Contributor
I have put together a small form with 3 different DropDownLists. The items to each DropDownList is loaded programatically during the onLoad event.
One is ddlIDType (where the customer enters their ID Type),
One is ddlState (where the customer enters their home state), and
One is ddlYear (where the customer enters the year of their birth).
In my code, I gather the information as follows:
The IDType field works the way it should, but State and Year do not. This leads me to believe that somehow my databinding is not working the way I want it to. The data shows up in each of the DropDownList when I run the webpage. When I click the btnSubmit button, State and Year consistantly return the topmost value, no matter which value was selected.
Could someone explain what is going on, and how I could correct this?
One is ddlIDType (where the customer enters their ID Type),
One is ddlState (where the customer enters their home state), and
One is ddlYear (where the customer enters the year of their birth).
In my code, I gather the information as follows:
Code:
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim MyList As New DropListData ' A class I have with all the states and years
ddlState.DataSource = MyList.StateList
ddlState.DataBind()
ddlYear.DataSource = MyList.YearList
ddlYear.DataBind()
With ddlIDType.Items
.Add("Driver's License")
.Add("Passport")
.Add("Alien Registration")
.Add("Govt. Employee")
.Add("Military")
End With
End Sub
Private Sub btnSubmit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSubmit.Click
Dim strCustomerInfo as String = ""
strCustomerInfo &= ddlIDType.SelectedItem.Text
strCustomerInfo &= ddlState.SelectedItem.Text
strCustomerInfo &= ddlYear.SelectedItem.Text
End Sub
Could someone explain what is going on, and how I could correct this?