gpt4 book ai didi

javascript - 模型未从 View 中获取所有属性值(仅新添加的属性)

转载 作者:行者123 更新时间:2023-11-28 03:20:33 25 4
gpt4 key购买 nike

这是我的模型

public class Patients
{
[Key]
public int PatientId { get; set; }
[Required]
public int HospitalId { get; set; }
public Hospital Hospital { get; set; }

[Required]
public string EntryDate { get; set; }

[Required]
public string Gender { get; set; }

[Required]
public string Age { get; set; }

[Required]
[MaxLength(3)]
[MinLength(1)]
[RegularExpression("^[0-9]*$", ErrorMessage = "يرجى ادخال الطول بصورة صحيحة")]
public string height { get; set; }

[Required]
public string Ethnicity { get; set; }

[Required]
public string Note { get; set; }

public string Condition { get; set; }

public string Name { get; set; }

[Display(Name = "الجنسية")]
public string Nationality { get; set; }

public string IDNumber { get; set; }

public string Status { get; set; }

public int Patient_ID { get; set; }
public int Injury_Type { get ; set ; }
public int Physical_Structure { get; set; }
public int Skin_Color { get; set; }
public int Face { get; set; }
public int Nose { get; set; }
public int Mouth { get; set; }
public int Forehead { get; set; }
public int Eyes { get; set; }
public int Head_Hair_Color { get; set; }
public int Pupil_Color { get; set; }
public int Hair_Type { get; set; }
public int Hair_Tall { get; set; }
public int Mustache_Beard { get; set; }
public int Eyebrows { get; set; }
public int Ears { get; set; }
public int Circumcision { get; set; }
public int Jewelery { get; set; }
public int Teeth { get; set; }
public int IndustrialTeeth { get; set; }
public int Det_ID { get; set; }
}

在 View 中

我试过这个方法

@Html.DropDownListFor(model => model.Injury_Type, ViewBag.lstInjuryType as SelectList, Lang.HomeTexts.SelectInjuryType, htmlAttributes: new { @class = "form-control" })
@Html.ValidationMessageFor(model => model.Injury_Type, "", new { @class = "text-danger" })

这样

@Html.DropDownList("Physical_Structure", ViewBag.lstPysicalStructure as SelectList, Lang.HomeTexts.PhysicalStructure, htmlAttributes: new { @class = "form-control" })
@Html.ValidationMessageFor(model => model.Physical_Structure, "", new { @class = "text-danger" })

我向模型添加了新属性,所有新属性均不采用任何值,仅将 int 设为 0,将字符串设为 null,旧属性照常保留,从 View 中获取正确的值。

提前致谢

最佳答案

你必须尝试,“公共(public)字符串 Injury_Type { 获取 ; 设置 ; }”,“公共(public)字符串Physical_Structure {获取;设置;}”

关于javascript - 模型未从 View 中获取所有属性值(仅新添加的属性),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59205720/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com