C# 如何解决:无法将“System.Decimal”类型的对象强制转换为“System.String”类型

C# 如何解决:无法将“System.Decimal”类型的对象强制转换为“System.String”类型,c#,sql,asp.net-core,razor,tag-helpers,C#,Sql,Asp.net Core,Razor,Tag Helpers,我创建了一个具有两个Decimal类型属性的类,之后我使用Visual Studio自动创建了控制器和视图……但当我输入Create Form的值时,出现以下错误: 无法将“System.Decimal”类型的对象强制转换为“System.String”类型 这里是我的类在模型中的小数变量部分: [Display(Name = "رسوم الدورة")] [StringLength(100, ErrorMessage = "العنوان طويل")] [DisplayFormat(Dat

我创建了一个具有两个Decimal类型属性的类,之后我使用Visual Studio自动创建了控制器和视图……但当我输入Create Form的值时,出现以下错误: 无法将“System.Decimal”类型的对象强制转换为“System.String”类型

这里是我的类在模型中的小数变量部分:

[Display(Name = "رسوم الدورة")]
[StringLength(100, ErrorMessage = "العنوان طويل")]
[DisplayFormat(DataFormatString = "{0:F2}", ApplyFormatInEditMode = true)]
public decimal CourseFees { get; set; }

[Display(Name = "الشهادة")]
public Certificate Certificate { get; set; }

[Display(Name = "رسوم الشهادة")]
[StringLength(100, ErrorMessage = "العنوان طويل")]
[DisplayFormat(DataFormatString = "{0:F2}", ApplyFormatInEditMode = true)]
public decimal CertificateCost { get; set; }
以下是Create FileOnly Decimal Part中的视图代码部分:

    <div class="form-group">
        <label asp-for="CourseFees" class="control-label"></label>
        <input asp-for="CourseFees" class="form-control" />
        <span asp-validation-for="CourseFees" class="text-danger"></span>
    </div>
    <div class="form-group">
        <label asp-for="Certificate" class="control-label"></label>
        <select asp-for="Certificate" asp-items="Html.GetEnumSelectList<Certificate>()" class="form-control"></select>
        <span asp-validation-for="Certificate" class="text-danger"></span>
    </div>
    <div class="form-group">
        <label asp-for="CertificateCost" class="control-label"></label>
        <input asp-for="CertificateCost" class="form-control" />
        <span asp-validation-for="CertificateCost" class="text-danger"></span>
    </div>

删除StringLength属性。

thanx我没有注意欢迎,我明白了。