For each statement

  • Thread starter Thread starter JJ297
  • Start date Start date
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!
 
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



Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
======================================
 
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

Juan T. Llibre, asp.net MVP
asp.net faq :http://asp.net.do/faq/
foros de asp.net, en español :http://asp.net.do/foros/
======================================








- 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
 
Back
Top