多选列表构造函数
根据 http://msdn.microsoft.com/en-us/library/dd470803 .aspx 中,MultiSelectList(IEnumerable, IEnumerable)
构造函数接受两个参数:items
和selectedValues
。
该文档并不完全明确,所以我只想澄清两点:
selectedValues
到底如何工作?此构造函数是否仅迭代集合并为每个元素设置.Selected = True
?selectedValues
必须是items
的子集吗?这是如何精确定义的(即只要它们的 ToString 值匹配)?
具体来说,我正在使用 a jQuery 多选插件 并尝试基本上完成演示中所做的事情该插件(即“选定”列表在初始化时已由某些元素填充)。
According to http://msdn.microsoft.com/en-us/library/dd470803.aspx, the MultiSelectList(IEnumerable, IEnumerable)
constructor takes in two parameters: items
and selectedValues
.
The documentation is not completely explicit so I just want to clarify two points:
- How exactly does
selectedValues
work? Does this constructor merely iterate through the collection and set.Selected = True
for each element? - Must
selectedValues
be a subset ofitems
? How is this defined, precisely (i.e. as long as their ToString values match)?
Specifically, I am playing with a jQuery multiselect plugin and am trying to do essentially what is being done in the demo of that plugin (i.e. the "selected" list is already populated by certain elements upon initialization).
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
HTML:
控制器代码:
我将其与 JQuery Multiselect 一起使用。工作代码...
The HTML:
Controller code:
I am using this with JQuery Multiselect. Working code...