Asp.net mvc 3 模型和类的组合。编辑数据
我有Asp.net mvc 3 模型和类的组合。编辑数据,asp.net-mvc-3,Asp.net Mvc 3,我有 [D] 控制器 AdmController.cs [D] 模型 [D] _产品 华硕 MAC.cs ……等等 [D] 附注 华硕cpu.cs 华硕存储器有限公司 ……等等 [D] 注(陆委会) mac_cpu.cs mac_memory.cs ……等等 [D] 看法 [D] 行政 编辑.cs ……其他 ASUS.cs namespace Store.Models._products { public class ASUS {
- [D] 控制器
- AdmController.cs
- [D] 模型
- [D] _产品
- 华硕
- MAC.cs
- ……等等
- [D] 附注
- 华硕cpu.cs
- 华硕存储器有限公司
- ……等等
- [D] 注(陆委会)
- mac_cpu.cs
- mac_memory.cs
- ……等等
- [D] _产品
- [D] 看法
- [D] 行政
- 编辑.cs
- ……其他
- [D] 行政
namespace Store.Models._products
{
public class ASUS
{
public virtual note_ASUS.asus_cpu class_cpu { get; set; }
public virtual note_ASUS.asus_memory class_memory { get; set; }
}
}
namespace Store.Models.note_ASUS
{
public class asus_cpu
{
[Key]
public int CpuID { get; set; }
public string CpuName { get; set; }
public decimal Price { get; set; }
}
}
namespace Store.Models.note_ASUS
{
public class asus_memory
{
[Key]
public int MemoryID { get; set; }
public string MemoryName { get; set; }
public decimal Price { get; set; }
}
}
@model Store.Models._products.ASUS
@using (Html.BeginForm())
{
@Html.ValidationSummary(true)
<fieldset>
<div class="editor-field">
@Html.EditorFor(model => model.Price)
</div>
<p>
<input type="submit" value="Save" />
</p>
</fieldset>
}
华硕cpu.cs
namespace Store.Models._products
{
public class ASUS
{
public virtual note_ASUS.asus_cpu class_cpu { get; set; }
public virtual note_ASUS.asus_memory class_memory { get; set; }
}
}
namespace Store.Models.note_ASUS
{
public class asus_cpu
{
[Key]
public int CpuID { get; set; }
public string CpuName { get; set; }
public decimal Price { get; set; }
}
}
namespace Store.Models.note_ASUS
{
public class asus_memory
{
[Key]
public int MemoryID { get; set; }
public string MemoryName { get; set; }
public decimal Price { get; set; }
}
}
@model Store.Models._products.ASUS
@using (Html.BeginForm())
{
@Html.ValidationSummary(true)
<fieldset>
<div class="editor-field">
@Html.EditorFor(model => model.Price)
</div>
<p>
<input type="submit" value="Save" />
</p>
</fieldset>
}
华硕内存.cs
namespace Store.Models._products
{
public class ASUS
{
public virtual note_ASUS.asus_cpu class_cpu { get; set; }
public virtual note_ASUS.asus_memory class_memory { get; set; }
}
}
namespace Store.Models.note_ASUS
{
public class asus_cpu
{
[Key]
public int CpuID { get; set; }
public string CpuName { get; set; }
public decimal Price { get; set; }
}
}
namespace Store.Models.note_ASUS
{
public class asus_memory
{
[Key]
public int MemoryID { get; set; }
public string MemoryName { get; set; }
public decimal Price { get; set; }
}
}
@model Store.Models._products.ASUS
@using (Html.BeginForm())
{
@Html.ValidationSummary(true)
<fieldset>
<div class="editor-field">
@Html.EditorFor(model => model.Price)
</div>
<p>
<input type="submit" value="Save" />
</p>
</fieldset>
}
查看-编辑.cs
namespace Store.Models._products
{
public class ASUS
{
public virtual note_ASUS.asus_cpu class_cpu { get; set; }
public virtual note_ASUS.asus_memory class_memory { get; set; }
}
}
namespace Store.Models.note_ASUS
{
public class asus_cpu
{
[Key]
public int CpuID { get; set; }
public string CpuName { get; set; }
public decimal Price { get; set; }
}
}
namespace Store.Models.note_ASUS
{
public class asus_memory
{
[Key]
public int MemoryID { get; set; }
public string MemoryName { get; set; }
public decimal Price { get; set; }
}
}
@model Store.Models._products.ASUS
@using (Html.BeginForm())
{
@Html.ValidationSummary(true)
<fieldset>
<div class="editor-field">
@Html.EditorFor(model => model.Price)
</div>
<p>
<input type="submit" value="Save" />
</p>
</fieldset>
}
返回-
传递到字典中的模型项的类型为
“系统.数据.实体.动态验证.产品--U 2B11F5A3B582AEEDC3A227AC890AB303622EA53BAA689279789468D341A905”,
但此词典需要类型为的模型项
'Store.Models.note_ASUS.ASUS_cpu'
实际上,
model.Price
不存在,因此不清楚您在这里试图实现什么我想制作一个模型,以便我能够参考单个文件asus\U cpu、asus\U内存等。。。它
editedit.cshtml
我的任务是将编辑面板添加到产品的属性中。名称、价格等…您是否尝试过Html.EditorFor(model=>model.class\u cpu)
?或者甚至可能Html.EditorFor(model=>model)
?如何修改代码使其工作?-它以什么方式不起作用?你所做的就是把你的代码扔到帖子里,然后说“它坏了。”