<InputDate id="birthday" class="form-control" placeholder=@Loc["birthday"] @bind-Value="PersModel.Pers.GeburtsDatum" />
public DateTime GeburtsDatum { get; set; }
I want the Default value to be any placeholder or Nothing only when date selected to be changed
pers.GeburtsDatumString = pers.GeburtsDatum.ToString("dd/M/yyyy", CultureInfo.InvariantCulture);
whenever i Change the
public DateTime? GeburtsDatum { get; set; } to be able to be 0 i get error at
pers.GeburtsDatumString = pers.GeburtsDatum.ToString("dd/M/yyyy", CultureInfo.InvariantCulture);
You can use the null-conditional operator to handle nullable DateTime:
pers.GeburtsDatumString = pers.GeburtsDatum?.ToString("dd/M/yyyy", CultureInfo.InvariantCulture);
// ^
This returns null
when pers.GeburtsDatum.HasValue
is false (ie, when the value is null).