简体   繁体   中英

debugging shows that all items in checkbox list as unchecked when there are 3checked

so im dynamically populating a checkbox list. I have confirmed that my text and values are correct for each checkbox but when I check a few and click my event button when I loop through the items they are all set to select=false...

    Dim resource As ListItem
    Dim SelectedHashTable As New Hashtable
    For Each resource In chkResources.Items
        If resource.Selected = True Then
            SelectedHashTable.Add(resource.Text, resource.Value)
        End If
    Next

set checkpoint at line 5 to view contents of hash table but it is never triggered. Even when I check all boxes. Anyone any idea?

Where are you dynamically populating the checkboxlist? If it's any time after the OnInit event, then the control's viewstate is not getting saved properly and your selections will be overridden on every postback. Try dynamically populating your list in the OnInit handler.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM