前端:
<form id="form1" runat="server">
<div>
<asp:CheckBoxList ID="cblTest" runat="server">
<asp:ListItem>A</asp:ListItem>
<asp:ListItem>B</asp:ListItem>
<asp:ListItem>C</asp:ListItem>
<asp:ListItem>D</asp:ListItem>
<asp:ListItem>E</asp:ListItem>
<asp:ListItem>F</asp:ListItem>
</asp:CheckBoxList>
<br />
<asp:Button ID="btnCV" runat="server" Text="Go" onclick="btnCV_Click"/>
</div>
</form>
后台:
protected void btnCV_Click(object sender, EventArgs e)
{
string value = "";
for (int i = 0; i < cblTest.Items.Count; i++)
{
value += cblTest.Items[i].Selected ? "1" : "0";
}
Response.Write(value);
}
效果: