Tuesday, January 1, 2008

Databound checkboxlist aggravation

Discovered today that the databound checkboxlist items' SELECTED property doesn't reflect what's in the VALUE property. The following code on the checkboxlist databound event hanlder cleared things up for me:

Protected Sub cblRoles_DataBound(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles cblRoles.DataBound

Dim loItem As ListItem = Nothing
For Each loItem In cblRoles.Items
loItem.Selected = loItem.Value
Next
End Sub


Now, when the form loads, the items with Value=True now display with the checkbox selected.

No comments: