简体   繁体   中英

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

I am new with .net c# and I have an error while I check if the model is valid, looking at ehe errors in the model it says: "The EndRepeat field is required."

Here are some of the lines of my model:

    [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; }
    }

any ideas ?

DateTime is a struct, and cannot be null. Try a DateTime? (which equates to a Nullable<DateTime> ) if you want to allow null values.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM