On my page, I'm filling in a CheckBoxList dynamically based on different user interactions.
CheckBoxList1.DataSource = cmd.ExecuteReader
CheckBoxList1.DataTextField = "name"
CheckBoxList1.DataValueField = "subgroup_id"
CheckBoxList1.DataBind() The values fill in the list, but when I submit the form the checkboxes don't show up as being selected.
Dim cli As ListItem
For Each cli In CheckBoxList1.Items
If cli.Selected Then
Response.Write("I've been selected:" + cli.Value.ToString + "<br />")
Else
Response.Write("I haven't been selected: " + cli.Value.ToString + "<br />")
End If
Next (in the case of this test code, I get back only "I haven't been selected" messages)
Is there an error in my method? Is there something I'm missing? Is there a different way of doing this?