mvc3 DataType.MultilineText中的多选框的数据类型是否正确?它们最终是从多对多类型关系派生而来的。
谢谢
一个频道可以有多个广告时段,一个广告时段可以有多个频道。
我目前的模型是:
[Display(Name = "Ad Slots")]
[DataType(DataType.MultilineText)]
public string[] AdSlots { get; set; }这对多选正确吗?
发布于 2012-02-01 06:03:32
persay没有为ASP.NET元素使用“类型”。您将利用HtmlHelper.ListBox()扩展方法。
此扩展方法返回一个多选列表框。
@Html.ListBox(
"YourFormFieldName",
new SelectList(new[] { "You can select this one", "and this one" })
)编辑:对于模型,您可以使用以下命令:
public class YourViewModel
{
public MultiSelectList YourItems { get; set; }
}然后在帖子上,你可以看到哪些项目被选中了。
发布于 2012-02-01 06:20:05
我认为你可以使用像System.Web.Mvc.MultiSelectList这样的东西,它接受一个IEnuermable集合。
有关更多信息,请查看本文:http://ittecture.wordpress.com/2009/04/30/tip-of-the-day-198-asp-net-mvc-listbox-controls/
好吧,你的编辑,我的答案可能不是那么有帮助,因为你很可能不希望你的模型引用MVC,但你可能会使用@Html.ListBox("AdSlots", new MultiSelectList(model.AdSlots)),因为它已经是可枚举的了。
发布于 2012-10-23 00:57:22
这个多行类型表示文本区域,而不是multiselect,它有一个带有multiselect属性的标记。
https://stackoverflow.com/questions/9087608
复制相似问题