簡體   English   中英

錯誤:未在模型中指示時,.net c#中的字段必填

[英]error:Field required in .net c# when not indicated in the model

我是.net c#的新手,在檢查模型是否有效時出現錯誤,查看模型中的錯誤: “需要EndRepeat字段。”

這是我的模型中的一些行:

    [Required(ErrorMessage = "Frecuencia requerida")]
    public int FrecuencyType
    {
        get { return this._frecuencyType; }
        set { this._frecuencyType = value; }
    }

    [DataType(DataType.Date)]
    public DateTime EndRepeat
    {
        get { return this._endRepeat; }
        set { this._endRepeat = value; }
    }

有任何想法嗎 ?

DateTime是一個結構,不能為null。 嘗試使用DateTime? (等於Nullable<DateTime> ),如果要允許空值。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM