checkboxlist给label赋值
来源:百度知道 编辑:UC知道 时间:2024/06/03 20:29:23
aspx
<asp:CheckBoxList ID="CheckBoxList1" runat="server"
onselectedindexchanged="CheckBoxList1_SelectedIndexChanged" AutoPostBack="True">
<asp:ListItem Value="1">aaaaa</asp:ListItem>
<asp:ListItem Value="2">bbbb</asp:ListItem>
<asp:ListItem Value="3">ccccc</asp:ListItem>
</asp:CheckBoxList>
<asp:Label ID="Label1" runat="server"></asp:Label>
.cs
protected void CheckBoxList1_SelectedIndexChanged ( object sender, EventArgs e )
{
CheckBoxList checkBoxList = sender as CheckBoxList;
string strSelectedTexts = String.Empty;
string strSelectedValues = String.Empty;
foreach ( ListItem item in checkBoxList.Items )
{
if (