I have a CheckBoxList that I have added to my web form using thefollowing code:
Dim oCheckBoxList As New CheckBoxList
When the user clicks a button I try to gather the selected values into a string but for some reason none of the checked items are gathered.
After the postback caused by the button click all of the items in the CheckListBox are unchecked. Is there a way to prevent this
Dim oCheckBoxList As CheckBoxList = CType(Me.Panel_Controls.FindControl(oControlName), CheckBoxList)
sValue = ""
For Each li As ListItem In oCheckBoxList.Items
If li.Selected Then
If sValue = "" Then
sValue = li.Text
sValue = sValue & "," & li.Text
'do whatever you need