title: checkboxlist selected items not gets select & inserts blank values in string
body: <p>I have a form in which data gets insert. There are some checkboxlist. CheckboxList binds with table in db. Now after selecting items it should enter selected values in db table but it inserts empty strings. </p>
  
  <p>I have two checkboxlist (products, payment) Payment works fine. problem is in products.</p>
  
  <p>VB code</p>
  
  <pre><code>Private Sub list_business_hospital_Load(sender As Object, e As EventArgs) Handles Me.Load
      Me.PopulateProducts()
      Me.PopulatePayments()
  End Sub
  
  Private Sub PopulateProducts()
      productsList.Items.Clear()
      Using conn As New MySqlConnection()
          conn.ConnectionString = ConfigurationManager _
              .ConnectionStrings("conio").ConnectionString()
          Using cmd As New MySqlCommand()
              cmd.CommandText = "select * from chemistsProducts"
              cmd.Connection = conn
              conn.Open()
              Using sdr As MySqlDataReader = cmd.ExecuteReader()
                  While sdr.Read()
                      Dim item As New ListItem()
                      item.Text = sdr("productName").ToString()
                      item.Value = sdr("productName").ToString()
                      'item.Selected = Convert.ToBoolean(sdr("IsSelected"))
                      productsList.Items.Add(item)
                  End While
              End Using
              conn.Close()
          End Using
      End Using
      productsList.Items.Insert(0, New ListItem("All", "All"))
  End Sub
  
  Private Sub PopulatePayments()
      Using conn As New MySqlConnection()
          conn.ConnectionString = ConfigurationManager _
              .ConnectionStrings("conio").ConnectionString()
          Using cmd As New MySqlCommand()
              cmd.CommandText = "select * from payment"
              cmd.Connection = conn
              conn.Open()
              Using sdr As MySqlDataReader = cmd.ExecuteReader()
                  While sdr.Read()
                      Dim item As New ListItem()
                      item.Text = sdr("paymentName").ToString()
                      item.Value = sdr("paymentID").ToString()
                      'item.Selected = Convert.ToBoolean(sdr("IsSelected"))
                      ListPayment.Items.Add(item)
                  End While
              End Using
              conn.Close()
          End Using
      End Using
      ListPayment.Items.Insert(0, New ListItem("All", "All"))
  End Sub
  
  Private Sub save_Click(sender As Object, e As EventArgs) Handles save.Click
          Dim selectedProducts As String = String.Empty
          For Each chk As ListItem In productsList.Items
              If chk.Selected = True Then
                  selectedProducts &amp;= "&lt;li&gt;" + chk.Text + "&lt;/li&gt;"
              End If
          Next
  
  
          Dim payments As String = String.Empty
          For Each chk As ListItem In ListPayment.Items
              If chk.Selected = True Then
                  payments &amp;= "&lt;li&gt;" + chk.Text + "&lt;/li&gt;"
              End If
          Next
  
          Try
              Dim str1 As String = "INSERT INTO chemists (`products`, `payment`) values ('" + selectedProducts + "', '" + payments + "')"
  
              Dim str2 As MySqlDataReader
              Dim adapter As New MySqlDataAdapter
              Dim command As New MySqlCommand
              command.CommandText = str1
              command.Connection = con
              adapter.SelectCommand = command
              con.Open()
              str2 = command.ExecuteReader
              con.Close()
              Response.Redirect("business-added.aspx")
          Catch ex As Exception
              Response.Write(ex)
          End Try
  End Sub
  </code></pre>
  
  <p>Here Payment gets inserted what I have selected. Problem is in selectedProducts</p>