Hi All,
I have populated a dropdown list with results from my SQL database and then added an additional entry called 'New Date' which sits as the top value in the list.
My issue is that when I select a value in the dropdown list it only ever appears to pull the value 'New Date' instead of the selected value.
my code for when the page first loads to populate the dropdown list:
my code for when I changed the selection in the dropdown list:
P.S I will changing the connection strings to read from the web.config before I finish.
If anyone can help that would be great.
Thanks,
Simon
I have populated a dropdown list with results from my SQL database and then added an additional entry called 'New Date' which sits as the top value in the list.
My issue is that when I select a value in the dropdown list it only ever appears to pull the value 'New Date' instead of the selected value.
my code for when the page first loads to populate the dropdown list:
VB.NET:
Dim sqlConnection1 As New SqlConnection("Server=*******; Database=nimbus; user=********; password=*******")
Dim cmd As New SqlCommand
cmd.CommandText = "SELECT startdate FROM availability"
cmd.CommandType = CommandType.Text
cmd.Connection = sqlConnection1
sqlConnection1.Open()
DeliveryList1.DataSource = cmd.ExecuteReader()
DeliveryList1.DataTextField = "startdate"
DeliveryList1.DataValueField = "startdate"
DeliveryList1.DataBind()
sqlConnection1.Close()
DeliveryList1.Items.Insert(0, New ListItem("New Date"))
my code for when I changed the selection in the dropdown list:
VB.NET:
Dim sqlConnection1 As New SqlConnection("Server=**********; Database=nimbus; user=**********; password=*********")
Dim cmd As New SqlCommand
Dim reader As SqlDataReader
Dim test As String
cmd.CommandText = "SELECT * FROM availability WHERE startdate = " + DeliveryList1.SelectedValue
cmd.CommandType = CommandType.Text
cmd.Connection = sqlConnection1
sqlConnection1.Open()
reader = cmd.ExecuteReader()
While reader.Read
If reader("monam").ToString = True Then monam.Checked = True Else monam.Checked = False
End While
P.S I will changing the connection strings to read from the web.config before I finish.
If anyone can help that would be great.
Thanks,
Simon