问题
I've been struggling with this, is there a way to do it using just configuration? Do I necessarily have to handle multi-selection manually, with post-backs?
<asp:CheckBoxList ID="uxVisibilityScopeCheckBoxList" runat="server" AutoPostBack="false" />
This definition only allows 1 checkbox to be selected.
Thanks!
EDIT:
Turns out we had a jscript somewhere deep, that was hooking to all of the input[type=checkbox] controls, and allowing to select only 1 checkbox of a same group.
Gotta be careful with those.
回答1:
<asp:CheckBoxList id="check1" AutoPostBack="false"
TextAlign="Right" runat="server">
<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>
Also look at this link
http://www.w3schools.com/aspnet/showasp.asp?filename=demo_checkboxlist
回答2:
public static Dictionary<int, string> ListDayWeek()
{
var days = new Dictionary<int, string>();
days.Add(1, "Monday");
days.Add(2, "Tuesday");
days.Add(3, "Wednesday");
days.Add(4, "Thursday");
days.Add(5, "Friday");
return days;
}
DropDownItem.DataSource = GlobalVar.ListItem();
DropDownItem.DataValueField = "Key";
DropDownItem.DataTextField = "Value";
DropDownItem.DataBind();
回答3:
Here is what you need:
<asp:CheckBoxList ID="uxVisibilityScopeCheckBoxList" runat="server" AutoPostBack="false" >
<asp:ListItem Value="1">Mercury</asp:ListItem>
<asp:ListItem Value="2">Venus</asp:ListItem>
</asp:CheckBoxList>
回答4:
Turns out we had a jscript somewhere deep, that was hooking to all of the input[type=checkbox] controls, and allowing to select only 1 checkbox of a same group.
Gotta be careful with those.
来源:https://stackoverflow.com/questions/13836540/how-to-enable-multi-selecting-in-asp-net-checkboxlist-control