I am trying to populate textboxes and a dropdown list on the page when loading using the following code:
All the fields populate apart fromthe dropdown list - Me.ddlCountries.SelectedItem.Selected = dtrReaderUser("Country")
I get the error "Input string was not in a correct format."
Any ideas how I would make the selected item the value stored in the database?
Code:
Dim dtrReaderUser As SqlDataReader = SqlCommand.ExecuteReader()
If dtrReaderUser.HasRows Then
While dtrReaderUser.Read()
Me.txtFirstname.Text = dtrReaderUser("Firstname")
Me.txtSurname.Text = dtrReaderUser("Surname")
Me.txtCompany.Text = dtrReaderUser("Company")
Me.txtAddressLine1.Text = dtrReaderUser("AddressLine1")
Me.txtAddressLine2.Text = dtrReaderUser("AddressLine2")
Me.txtAddressLine3.Text = dtrReaderUser("AddressLine3")
Me.txtTown.Text = dtrReaderUser("Town")
Me.txtPostcode.Text = dtrReaderUser("Postcode")
Me.ddlCountries.SelectedItem.Selected = dtrReaderUser("Country")
Me.txtPhone.Text = dtrReaderUser("ContactPhone")
Me.txtEmail.Text = dtrReaderUser("EmailAddress")
End While
All the fields populate apart fromthe dropdown list - Me.ddlCountries.SelectedItem.Selected = dtrReaderUser("Country")
I get the error "Input string was not in a correct format."
Any ideas how I would make the selected item the value stored in the database?