Eme*_*ca. 3 c# asp.net checkboxlist
有没有办法可以在asp.net中包含一个checkboxlist,这样可以说如果列表中有20个复选框,则有两列10个.示例:
Box Box
Box Box
Box Box
Box Box
Box Box
Box Box
Box Box
Box Box
Run Code Online (Sandbox Code Playgroud)
我目前的代码只是:
<asp:CheckBoxList ID="Numbers" runat="server" AutoPostBack = "true">
<asp:ListItem> 1 </asp:ListItem>
<asp:ListItem> 2 </asp:ListItem>
<asp:ListItem> 3 </asp:ListItem>
<asp:ListItem> 4 </asp:ListItem>
<asp:ListItem> 5 </asp:ListItem>
<asp:ListItem> 6 </asp:ListItem>
<asp:ListItem> 7 </asp:ListItem>
<asp:ListItem> 8 </asp:ListItem>
<asp:ListItem> 9 </asp:ListItem>
...ect
</asp:CheckBoxList>
Run Code Online (Sandbox Code Playgroud)
我想必须有某种asp标记或某些东西,以允许我清理这个复选框列表.
小智 5
您要找的是RepeatColumns物业和RepeatDirection物业.像这样的东西:
<asp:CheckBoxList ID="Numbers" runat="server" AutoPostBack = "true"
RepeatColumns="2" RepeatDirection="Vertical">
<asp:ListItem> 1 </asp:ListItem>
<asp:ListItem> 2 </asp:ListItem>
<asp:ListItem> 3 </asp:ListItem>
<asp:ListItem> 4 </asp:ListItem>
<asp:ListItem> 5 </asp:ListItem>
<asp:ListItem> 6 </asp:ListItem>
<asp:ListItem> 7 </asp:ListItem>
<asp:ListItem> 8 </asp:ListItem>
<asp:ListItem> 9 </asp:ListItem>
...ect
</asp:CheckBoxList>
Run Code Online (Sandbox Code Playgroud)
根据以下参考,您还可以使用RepeatDirection枚举以编程方式在代码隐藏中设置此属性:
Numbers.RepeatDirection = RepeatDirection.Vertical;
Numbers.RepeatColumns = 2;
Run Code Online (Sandbox Code Playgroud)
请参阅此参考:如何:在CheckBoxList Web服务器控件中设置布局