0

Im having a problem with my checkbox list. I'm able to loop though it, but I can not seem to find that items are checked. Im coding this in VB.net 2010 and asp.net In my for each i always get False on selected.

Here is some of my code:

Protected Sub cmdSend_Click(sender As Object, e As System.EventArgs) Handles cmdSend.Click
    'Check for checked users. 
    Dim lqText As New lqAlarmAndGoDataContext

    Try
        For Each foundCheckedUser In cbMembers.Items
            If foundCheckedUser.Selected Then
                Dim objText As New tbTxtMessageQueue
                With objText
                    .TxtFrom = "[email protected]"
                    .TxtTo = foundCheckedUser.value
                    .TxtBoddy = tbMessage.Text
                    .SentFlag = False
                End With
                lqText.tbTxtMessageQueues.InsertOnSubmit(objText)
                lqText.SubmitChanges()
            End If
          Next
    Catch ex As Exception

    End Try


End Sub
1
  • Where do you load the checkedlistbox? Commented Oct 24, 2012 at 16:51

2 Answers 2

2

Where do you bind your data to the checkbox?

Make sure it's not being rebinded before the button onclick by using

If Page.IsPostBack Then

Also, make sure your viewstate are enabled

Sign up to request clarification or add additional context in comments.

Comments

2

Are you rebinding cbMembers on each postback? That will cause your selection info to be lost. Try refactoring your code so that cbMembers only gets bound once.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.