hi !
i have made some code for a checkboxlist the items if are selected or not,and then to put them in my database.but im having a problem.even if i select my items they always apears unselected .

Dim ckbox As ListItem

        For Each ckbox In chbl.Items
            If ckbox.Selected = True Then
                objBLRegjistrimi.fnbooksubject(txtISBN.Text, chbl.SelectedValue)
            End If
        Next

'ckbox.selected' never becomes true,so never pass ' objBLRegjistrimi.fnbooksubject(txtISBN.Text, chbl.SelectedValue)'

i don't know why this happens.
thank you

Recommended Answers

All 6 Replies

Change If ckbox.Selected = True Then to If ckbox.Checked Then I think that's what you want.

HTH

Change If ckbox.Selected = True Then to If ckbox.Checked Then I think that's what you want.

HTH

thank you but
checked' is not a member of 'System.web.Ui.Webcontrols.checkboxlist'

If the applicaion is a web applicaion check to confirm that you are rebinding to the checkboxlist at every postback.

sorry i mean you need to confirm that you are not rebinding at every postback.

yes ,it is a web application.
sorry but what does it mean,because i dont understand what you want to tell me.can you explain me better
thank you

If you are binding data to the checkboxlist at the page load and the code doing the binding is not within if not ispostback. The checkboxlist will never be selected.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.