调试显示,当有 3 个已选中时,复选框列表中的所有项目均未选中
所以我动态填充复选框列表。我已经确认每个复选框的文本和值都是正确的,但是当我检查几个复选框并单击事件按钮时,当我循环浏览项目时,它们都设置为 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
在第 5 行设置检查点以查看内容哈希表,但它永远不会被触发。即使我选中所有复选框。有人有什么想法吗?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您在哪里动态填充复选框列表?如果在
OnInit
事件之后的任何时间,则控件的视图状态不会正确保存,并且您的选择将在每次回发时被覆盖。尝试在OnInit
处理程序中动态填充列表。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 theOnInit
handler.