CheckBoxList Question

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
 
P

Patrick.O.Ige

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

Stephen

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
 
P

Patrick.O.Ige

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,780
Messages
2,569,611
Members
45,278
Latest member
BuzzDefenderpro

Latest Threads

Top