CheckBoxList Question

  • Thread starter Thread starter Stephen
  • Start date Start date
S

Stephen

Hi,

I have a question on checkboxlist, suppose I have a checkboxlist and has
listitems like
USA
Canada
UK
Germany
Australia
Suppose I have a resultset that has values (USA, UK and Australia)
How can set the values in the checkboxlist to selected/enabled?

Thanks,
Stephen
 
Stephen are you interested in getting the selectedItem.Value of the
Checkboxlist?
Maybe try posting some snippet code.
Patrick
 
Hi Patrick,

Thanks for the info, actually I have a Solution but please do let me know if
there is a better way of doing it. This is how I approached it. I loop
through the dataset and check for the column that corresponds to the one
that has to be linked/matched to the checkbox and if it matched
then.selected = true

For iSystems = 0 To dsSystems.Tables(0).Rows.Count - 1
If dsSystems.Tables(0).Rows(iSystems)(1).ToString = "Canada" Then
For iChkBox = 0 To chkBoxCanada.Items.Count - 1
If chkBoxCanada.Items(iChkBox).Value =
dsSystems.Tables(0).Rows(iSystems)(0).ToString Then
chkBoxCanada.Items(iChkBox).Selected = True

End If

Next

End If
Next

Is there a better way of doing this?
Thanks,
Stephen
 
Good approach

Stephen said:
Hi Patrick,

Thanks for the info, actually I have a Solution but please do let me know if
there is a better way of doing it. This is how I approached it. I loop
through the dataset and check for the column that corresponds to the one
that has to be linked/matched to the checkbox and if it matched
then.selected = true

For iSystems = 0 To dsSystems.Tables(0).Rows.Count - 1
If dsSystems.Tables(0).Rows(iSystems)(1).ToString = "Canada" Then
For iChkBox = 0 To chkBoxCanada.Items.Count - 1
If chkBoxCanada.Items(iChkBox).Value =
dsSystems.Tables(0).Rows(iSystems)(0).ToString Then
chkBoxCanada.Items(iChkBox).Selected = True

End If

Next

End If
Next

Is there a better way of doing this?
Thanks,
Stephen
 
Back
Top