在Asp.net代码后台为复选框列表设置滚动条?

3

我尝试了以下代码,但它没有起作用。请帮我找到解决方案。

源代码:

CheckBoxList chklstProducts = new CheckBoxList();
chklstProducts.DataSource = lstProduct;
chklstProducts.ID = "chklstProducts" + (i + 1);
chklstProducts.DataValueField = "ProductID";
chklstProducts.DataTextField = "ProductName";
chklstProducts.DataBind();
cell6.Height = 20;

Thanks in advance

2个回答

2

默认情况下,滚动不起作用。您可能需要将复选框列表控件放置在一个 div 内。

<div style="height:100px;overflow:auto;"> <asp:CheckBoxList></asp:CheckBoxList> </div> 

2

您需要使用CSS来实现带有CheckboxList的垂直滚动条。您只需要将列表包含在此div中即可

<div style="width:200px; height:300px; overflow-y:auto">
// Checkbox List
</div>

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接