简体   繁体   English

如何在新行添加复选框项目?

[英]How to add the checkbox item at the new line?

I have a checkbox list like below:我有一个如下所示的复选框列表:

<asp:CheckBoxList  id="chx" runat="server" repeatdirection="Horizontal"> <asp:ListItem value="OPTION1">Option 1</asp:ListItem>
<asp:ListItem value="OPTION2">Option 2</asp:ListItem>
<asp:ListItem value="OPTION3">Option 3</asp:ListItem><
asp:ListItem value="OPTION4">Option 4</asp:ListItem>
</asp:CheckBoxList>

And I am dynamically adding the list items to this checkbox using the following C# code:我使用以下 C# 代码将列表项动态添加到此复选框:

chx.Items.Clear();
while(dr.Read()){
    if(dr.GetOracleString(0).ToString()!="Null"){
        chx.Items.Add(dr.GetOracleString(0).ToString());
    }
}

My requirement is whenever the new item is added in the checkboxlist, it should check whether the new item is going beyond the border(fixed width) of the page and if so the new item should go the next line of checkboxlist without overlapping below control .我的要求是每当在复选框列表中添加新项目时,它应该检查新项目是否超出页面的边框(固定宽度),如果是,新项目应该进入复选框列表的下一行,而不会在控件下方重叠
Please help me to fix this.请帮我解决这个问题。在此处输入图片说明

您可以使用属性RepeatColumns

RepeatColumns="3"

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM