C# 试图将EditorFor与ICollection一起使用<;字符串>;在ASP.NET MVC3视图中?

C# 试图将EditorFor与ICollection一起使用<;字符串>;在ASP.NET MVC3视图中?,c#,.net,asp.net-mvc-3,editorfor,C#,.net,Asp.net Mvc 3,Editorfor,我试图在Create视图中显示一个类对象,其中属性是ICollection 例如 namespace StackOverflow.Entities { public class Question { public int Id { get; set; } .... public ICollection<string> Tags { get; set; } } } namespace StackOverflow.

我试图在
Create
视图中显示一个类对象,其中属性是
ICollection

例如

namespace StackOverflow.Entities
{
    public class Question
    {
        public int Id { get; set; }
        ....
        public ICollection<string> Tags { get; set; }
    }
}
namespace StackOverflow.Entities
{
公开课问题
{
公共int Id{get;set;}
....
公共ICollection标记{get;set;}
}
}
如果视图类似于StackOverflow“询问问题”页面,其中
标记
html元素是单个
输入框
。。我不确定如何在ASP.NET MVC3视图中做到这一点

有什么想法吗


我尝试使用
EditorFor
,但浏览器中没有显示任何内容,因为它不确定如何呈现字符串集合。

首先用属性装饰视图模型:

public class Question
{
    public int Id { get; set; }

    [UIHint("tags")]
    public ICollection<string> Tags { get; set; }
}
然后您可以编写一个自定义编辑器模板(
~/Views/Shared/EditorTemplates/tags.cshtml
):


这不应该是
~/Views/Shared/EditorTemplates/tags.cshtml
?@MystereMan,是的,应该是。感谢您的关注。当它发回时,我如何保存收集的数据?我尝试在编辑器模板中添加一个
foreach
,使用
HiddenFor
s,但似乎不起作用:(
@model StackOverflow.Entities.Question
@Html.EditorFor(x => x.Tags)
@model ICollection<string>
@Html.TextBox("", string.Join(",", Model))
@model StackOverflow.Entities.Question
@Html.EditorFor(x => x.Tags, "tags")