Wednesday, February 28, 2007

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. Whew!

1 comment:

spookybrain said...

Way to go Chuck. Congrats on the new blog.

About Me

Principal Partner at NetPositive, Inc., St. Louis, MO.