Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/asp.net-mvc-3/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Asp.net mvc 3 模型和类的组合。编辑数据_Asp.net Mvc 3 - Fatal编程技术网

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] 行政
      • 编辑.cs
      • ……其他
ASUS.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>
}
华硕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内存等。。。它
edit
edit.cshtml
我的任务是将编辑面板添加到产品的属性中。名称、价格等…您是否尝试过
Html.EditorFor(model=>model.class\u cpu)
?或者甚至可能
Html.EditorFor(model=>model)
?如何修改代码使其工作?-它以什么方式不起作用?你所做的就是把你的代码扔到帖子里,然后说“它坏了。”