我是ASP.net MVC的新手,我使用viewmodel而不是viewbags来填充我的下拉菜单,因为我看到大多数人推荐他们.我有一个光滑的用户界面,可以进行级联下拉和自动填充(此处未显示),但我似乎无法将我的数据保存回数据库.
楷模:
public partial class Car
{
public int CarID { get; set; }
public string CarName { get; set; }
public int ModelID { get; set; }
public int ManufacturerID { get; set; }
public int CarColorID { get; set; }
public Nullable<decimal> Price { get; set; }
public string Description { get; set; }
public virtual CarColor CarColor { get; set; }
public virtual Manufacturer Manufacturer { get; set; }
public virtual CarModel CarModel { get; set; …Run Code Online (Sandbox Code Playgroud)