0

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 ?

aricca
  • 1
  • 1

1 Answers1

1

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

Jonesopolis
  • 25,034
  • 12
  • 68
  • 112