Asp.net 提交和保存包含多个ICollection项的表单最有效的方法是什么?
我让用户填写一份表格,要求提供大量“教育背景”数据:Asp.net 提交和保存包含多个ICollection项的表单最有效的方法是什么?,asp.net,asp.net-mvc-3,razor,icollection,Asp.net,Asp.net Mvc 3,Razor,Icollection,我让用户填写一份表格,要求提供大量“教育背景”数据: public class EducationalBackground { public int EducationalBackgroundID { get; set; } public string UniversityOrCollege { get; set; } public string AreaOfStudy { get; set; } public string Degree { get; se
public class EducationalBackground
{
public int EducationalBackgroundID { get; set; }
public string UniversityOrCollege { get; set; }
public string AreaOfStudy { get; set; }
public string Degree { get; set; }
public int YearReceived { get; set; }
public virtual Application Application { get; set; }
}
以下是完整应用程序的模型:
public class Application
{
public int ApplicationID { get; set; }
public Profile BasicInfoGatheredFromProfile { get; set; }
public virtual ICollection<EducationalBackground> EducationalBackground { get; set; }
public bool WillingToTravel { get; set; }
}
公共类应用程序
{
public int ApplicationID{get;set;}
公共配置文件基本配置文件从配置文件{get;set;}
公共虚拟ICollection EducationalBackground{get;set;}
公共bool WillingToTravel{get;set;}
}
我正在制作一个页面,用户可以在其中填写完整的应用程序,它将呈现一个局部视图,允许他们添加一个“教育背景”数据块,直到他们有多少
允许用户在此应用程序中添加无限数量的“教育背景”信息的最有效方式是什么
我的想法是:我需要一个ViewModel,以便在发布表单时考虑教育背景的ICollection。jQuery是为“教育背景”添加额外字段的最干净的方法吗
除了可以提供的任何信息外,还可以提供一个示例帖子,我们将不胜感激。您查看过这篇博客帖子吗?它使用MVC2,但同样的概念也适用于MVC3。@nemesv我现在有了。看起来几乎完美。他们在模型中不使用ID——我是否不需要使用ID?或者他们不使用ID是因为我不知道的其他原因吗?@miscusermandude他们正在使用ID。他们声明使用
HTML.TextBoxFor
“以避免手动构建元素ID”。通过使用这种机制,MVC将自动将表单中的值分配给操作中的参数。