我在一个 div 中有一个复选框列表,它显示来自 db 的名称 gettin 数据。我必须在 OnSelectedIndexChanged 上找出这个复选框列表的长度,才能对选定的项目/值进行一些数据库操作。谁来帮帮我!!!!!!
问问题
1939 次
2 回答
0
假设您的CheckBoxList
变量被调用,请checkboxlist
使用以下内容来确定项目的数量:
int numberOfItems = checkboxlist.Items.Count
该CheckBoxList.Items
属性返回一个ListItemCollection
包含您的控件,从这里您可以使用 count 属性来确定列表的长度或它包含的项目数。
于 2010-08-18T07:25:10.420 回答
0
<asp:CheckBoxList id="Check1" RepeatLayout="flow" runat="server" AutoPostBack="true" >
<asp:ListItem>Item 1</asp:ListItem>
<asp:ListItem>Item 2</asp:ListItem>
<asp:ListItem>Item 3</asp:ListItem>
<asp:ListItem>Item 4</asp:ListItem>
<asp:ListItem>Item 5</asp:ListItem>
<asp:ListItem>Item 6</asp:ListItem>
</asp:CheckBoxList>
Protected Sub Check1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) 处理 Check1.SelectedIndexChanged
Dim items As String = Check1.Items.Count
结束子
于 2010-08-18T07:29:40.937 回答