[英]Multi-select dropdown list in ASP.NET
asp.net是否存在带有复选框(webcontrol)的任何好的多选下拉列表?
非常感谢
您可以使用System.Web.UI.WebControls.CheckBoxList
控件或使用System.Web.UI.WebControls.ListBox
控件,并将SelectionMode
属性设置为Multiple
。
jQuery Dropdown Check List可用于将常规的多选html元素转换为下拉复选框列表,它可以在客户端上运行,因此可以与任何服务器端技术一起使用:
(来源: googlecode.com )
试试这个直接从CheckBoxList继承的服务器控件(免费,开源): http : //dropdowncheckboxes.codeplex.com/
我在http://dropdowncheckboxes.codeplex.com/上使用了开源控件,对此非常满意。 我的补充是允许一个已检查文件列表只使用文件名而不是完整路径,如果'selected'标题太长。 在回发处理程序中调用我的添加而不是UpdateSelection:
// Update the caption assuming that the items are files<br/>
// If the caption is too long, eliminate paths from file names<br/>
public void UpdateSelectionFiles(int maxChars) {
StringBuilder full = new StringBuilder();
StringBuilder shorter = new StringBuilder();
foreach (ListItem item in Items) {
if (item.Selected) {
full.AppendFormat("{0}; ", item.Text);
shorter.AppendFormat("{0}; ", new FileInfo(item.Text).Name);
}
}
if (full.Length == 0) Texts.SelectBoxCaption = "Select...";
else if (full.Length <= maxChars) Texts.SelectBoxCaption = full.ToString();
else Texts.SelectBoxCaption = shorter.ToString();
}
HTML不支持带复选框的下拉列表。 您可以拥有下拉列表或复选框列表。 您可以使用javascript和隐藏div来伪造dropdowncheckbox列表,但这不如标准复选框列表那么可靠。
当然第三方控件看起来像一个下拉复选框列表,但他们正在使用div技巧。
您还可以使用双列表框,通过在两个列表之间来回移动项来处理多选。 这样做的另一个好处是,即使总项目列表很长,也可以轻松地一次查看所有选定的项目
(想象一下世界上每个城市的清单,只选择第一个和最后一个城市)
我喜欢Infragistics控件。 WebDropDown拥有您所需要的。 唯一的缺点是它们可能有点花钱。
这是一个很酷的ASP.NET Web控件,名为Multi-Select List Field,位于http://www.xnodesystems.com/ 。 它能够:
(1)多选; (2)自动完成; (3)验证。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.