lundi 17 juillet 2017

How do I get comma-delimited data from SQL database into checkboxes in vb?

Dim Entities As String() = BillingEntity.Split(",")
For index As Integer = 0 To Entities.Length - 1 Step 1
    If (Entities(index) = CheckBoxClinic.Text) Then
           CheckBoxClinic.Checked = True     
    ElseIf (Entities(index) = CheckBoxHospital.Text) Then
           CheckBoxHospital.Checked = True
    ElseIf (Entities(index) = CheckBoxExpressCare.Text) Then
           CheckBoxExpressCare.Checked = True
    ElseIf(Entities(index) = CheckBoxAspen.Text) Then
           CheckBoxAspen.Checked = True
    End If
    MessageBox.Show(Entities(index))
    Next
Loop

I'm currently reading in from a SQL database to VB. I've got a field in SQL that has more than one item in it, delimited by commas. Only the first checkbox gets checked from this info though I know both from breakpoints and from my message box that other values pass through without triggering their associated checkbox events. I've tried hardcoding the values in to test, but still only the first statement evaluates to true. I've tried checking more than one checkbox on the first condition and that does make both checkboxes trigger. However, this doesn't function the way I need. Any ideas welcome. I do have the data databound to a gridview at the top of my form, but am not using databinding with the controls and maybe I should be.




Aucun commentaire:

Enregistrer un commentaire