Hi,
Is there any way of binding to a nullable DateTime or is there a recommended approach for handling null/empty values. I think this question could apply to any of the controls that bind to a struct or an in-built type like Int/Decimal.
Thanks,
Nick.
8 Answers, 1 is accepted

Nullable DateTime is still not supported and you can track this feature in the following page: https://feedback.telerik.com/blazor/1410422-binding-to-nullable-value.
Regards,
Marin Bratanov
Progress Telerik UI for Blazor

I would personally have expected that to work too, in your place. We simply haven't gotten around to clearing up all of those things, with all the changes and new things that are happening. It's early days for Blazor, and even more so for component suites on it.
--Marin

Hello Sean,
What version of Telerik UI for Blazor are you running? Can you confirm you are on 1.6.0 and that you have .NET Core 3 Preview 8 installed?
I just tested the following code and it seems to work fine for me (I am also attaching a video of my test at the end of this post):
@using Telerik.Blazor.Components.DatePicker
@using Telerik.Blazor.Components.DateInput
<TelerikDatePicker @bind-Value="theDate"></TelerikDatePicker>
<br />
The selected date is: @theDate
<br />
<TelerikDateInput @bind-Value="@StartDate" Format="MM/dd/yyyy HH:mm:ss"></TelerikDateInput>
<br />
The date input date is: @StartDate
@code {
DateTime? theDate;
DateTime? StartDate { get; set; } = new DateTime(2020, 1, 1);
}
Regards,
Marin Bratanov
Progress Telerik

Hello...
Is the DatePicker having issues with nullable date values ?
when a value is null we get the default value of 1/1/0001
how do we get around this issue .. we still want to preserve the null value.. have you guys fixed this yet?
This post is dated from Jun 2019.. so.. i hope there is an alternative solution a year and a half later..
Please advice.. Thanks !!!
Hello,
The DatePicker should not have an issue with the nullable DateTime type. Below, I have prepared two examples of the DatPicker using both nullable and non-nullable DateTime objects.
<h3>Nullable DateTimePicker</h3>
<TelerikDatePicker @bind-Value="@HireDate"></TelerikDatePicker>
<h3>Non-nullable DateTimePicker</h3>
<TelerikDatePicker @bind-Value="@VacationDate"></TelerikDatePicker>
@code {
public DateTime? HireDate { get; set; } //nullable DateTime - default value null
public DateTime VacationDate { get; set; } //non-nullable - default value 1/1/0001
}
Regards,
Svetoslav Dimitrov
Progress Telerik
Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.