I need a little help with selecting checkboxlist (cblStates) items based on a sql query using a datareader. My sql query is returning a list of StateIDs that I need to match up with a checkboxlist's item values. If the checkboxlist item value matches one of the returned StateIDs, I want that checkbox to be checked.
The code below is where I am so far - just can't figure out what to do with the data being read.
Thanks for the help - I'm definitely a beginner in this area.
Dim conString As String
conString = ConfigurationManager.ConnectionStrings("TTAPSDBConnectionString").ConnectionString
Dim sqlCon As New SqlConnection(conString)
Dim reader As SqlDataReader
If sqlCon.State = ConnectionState.Closed Then
Dim cmd As New SqlCommand
cmd.Connection = sqlCon
cmd.CommandType = CommandType.Text
cmd.CommandText = "SELECT StateID FROM Product_States WHERE ProductID = " & Session("ProductID")
reader = cmd.ExecuteReader
'Trying to figure out what to do here.