For each statement

J

JJ297

How do I read through the database to get the items that are checked
to appear on my page? I have a checkboxlist on the page.

I wrote this but it brings back all items checked...

For Each l As ListItem In CheckBoxList1.Items

l.Selected = True

Next

Any suggestions? Thanks!
 
J

Juan T. Llibre

re:
!> For Each l As ListItem In CheckBoxList1.Items
!>
!> l.Selected = True
!>
!> Next

Try adding an if condition and adding code to do something with the selected items :

For Each l As ListItem In CheckBoxList1.Items
IF
l.Selected = True
' do something here
END IF
Next
 
J

JJ297

re:
!> For Each l As ListItem In CheckBoxList1.Items
!>
!> l.Selected = True
!>
!> Next

Try adding an if condition and adding code to do something with the selected items :

For Each l As ListItem In CheckBoxList1.Items
IF
l.Selected = True
' do something here
END IF
Next










- Show quoted text -

I want the items to be checked on the screen so would I do this?

Dim chk = checked

For Each l As ListItem In CheckBoxList1.Items
IF
l.Selected = True
Checkboxlist1.items = chk

Next
 

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

No members online now.

Forum statistics

Threads
474,144
Messages
2,570,823
Members
47,369
Latest member
FTMZ

Latest Threads

Top