Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/272.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/37.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
C# MVC ToString代替模板_C#_Asp.net_Asp.net Mvc_Razor - Fatal编程技术网

C# MVC ToString代替模板

C# MVC ToString代替模板,c#,asp.net,asp.net-mvc,razor,C#,Asp.net,Asp.net Mvc,Razor,我正在尝试使用EF为MVC5中的对象列表获取模板 我没有得到我提供的模板,而是得到了toString的“Class”(模型中的一个proerties) 我找遍了所有的地方,没有找到任何可以帮助我的东西 任何帮助都将不胜感激 我得到的是: 这是一个该死的班级 我有以下资料: ClassSpellLevelPair.cshtml(尝试将其放入共享、EditorTemplates和带有Create.cshtml的文件夹中): @model Analyzer.Models.ClassSpellLevel

我正在尝试使用EF为MVC5中的对象列表获取模板

我没有得到我提供的模板,而是得到了toString的“Class”(模型中的一个proerties)

我找遍了所有的地方,没有找到任何可以帮助我的东西

任何帮助都将不胜感激

我得到的是:

这是一个该死的班级

我有以下资料:

ClassSpellLevelPair.cshtml(尝试将其放入共享、EditorTemplates和带有Create.cshtml的文件夹中):

@model Analyzer.Models.ClassSpellLevelPair
@Html.HiddenFor(m=>m.Id)
@LabelFor(model=>model.Class.Name)
@ValueFor(model=>model.SpellLevel)
在create.cshtml中:

@model Analyzer.Models.ClassSpellLevelPair
<div>
    @Html.HiddenFor(m => m.Id)
    @Html.LabelFor(model => model.Class.Name)
    @Html.ValueFor(model => model.SpellLevel)
</div>    
<div class="form-group">
    @Html.LabelFor(m => m.Levels, new { @class = "control-label col-md-3" })
    <div class="col-md-9">
        @Html.EditorFor(m => m.Levels, "ClassSpellLevelPair")
    </div>
 <div>

@LabelFor(m=>m.Levels,新的{@class=“controllabel col-md-3”})
@EditorFor(m=>m.Levels,“ClassSpellLevelPair”)
这些模型是:

public class Spell : Entity
{
    ...
    [Display(Name = "Levels")]
    public virtual ICollection<ClassSpellLevelPair> Levels { get; set; }
    ...
}

public class ClassSpellLevelPair : Entity
{
    public ClassSpellLevelPair()
    {

    }

    public ClassSpellLevelPair(Class c, int? l = null)
    {
        Class = c;
        SpellLevel = l;
    }

    public Class Class { get; set; }

    public int? SpellLevel { get; set; }
}

public class Entity
{
    public Entity()
    {
        Id = Guid.NewGuid();
    }

    [Key]
    public Guid Id { get; set; }
}
公共类拼写:实体
{
...
[显示(Name=“Levels”)]
公共虚拟ICollection级别{get;set;}
...
}
公共类类对:实体
{
公共类spelllevelpair()
{
}
公共类SpellLevelPair(类c,int?l=null)
{
类别=c;
拼写级别=l;
}
公共类{get;set;}
公共int?拼写级别{get;set;}
}
公共类实体
{
公共实体()
{
Id=Guid.NewGuid();
}
[关键]
公共Guid Id{get;set;}
}
编辑:为ClassSpellLevelPair.cshtml添加了文件夹数据,发现“EditorTemplates”文件夹实际上是“Shared\EditorTemplates”


很明显,谷歌搜索总共花了6个小时。

哪个文件夹位于
ClassSpellLevelPair.cshtml
中?