DatePicker render exception bug?

Hi,

I have a DatePicker set for time use only and during the loading of the form I assign any existing times from my database as TimeSpans to the datepicker.

I use an event to simply get the time part of the date time and add that to the form data. This works really well.

Only issue is if the form loads with say 1 hour in the time picker and the user sets it to 0 hours and 0 minutes it throws a render exception. That said if a user sets it to 1 hour then back to 0 hours and 0 minutes without clicking save there is no exception. Odd.

I know its not my event as even if I delete the event this throws an exception.

Any help with resolving this would be great as currently its a bit of a showstopper :blush:

 dotnet: warn: Microsoft.AspNetCore.Components.Server.Circuits.RemoteRenderer[100]
      Unhandled exception rendering component: Object reference not set to an instance of an object.
System.NullReferenceException: Object reference not set to an instance of an object.
   at Radzen.Blazor.RadzenDatePicker`1.OnChange()
   at Radzen.Blazor.RadzenDatePicker`1.<BuildRenderTree>b__0_1(Double v)
   at Microsoft.AspNetCore.Components.ComponentBase.CallStateHasChangedOnAsyncCompletion(Task task)
   at Radzen.Blazor.RadzenNumeric`1.UpdateValueWithStep(Boolean stepUp)
   at Microsoft.AspNetCore.Components.ComponentBase.CallStateHasChangedOnAsyncCompletion(Task task)
   at Microsoft.AspNetCore.Components.RenderTree.Renderer.GetErrorHandledTask(Task taskToHandle)

dotnet: fail: Microsoft.AspNetCore.Components.Server.Circuits.CircuitHost[111]
      Unhandled exception in circuit 'qHHxZMd7jV2A0V5H-3FcdQnmu4brrVbbtyDqROfd_EU'.
System.NullReferenceException: Object reference not set to an instance of an object.
   at Radzen.Blazor.RadzenDatePicker`1.OnChange()
   at Radzen.Blazor.RadzenDatePicker`1.<BuildRenderTree>b__0_1(Double v)
   at Microsoft.AspNetCore.Components.ComponentBase.CallStateHasChangedOnAsyncCompletion(Task task)
   at Radzen.Blazor.RadzenNumeric`1.UpdateValueWithStep(Boolean stepUp)
   at Microsoft.AspNetCore.Components.ComponentBase.CallStateHasChangedOnAsyncCompletion(Task task)
   at Microsoft.AspNetCore.Components.RenderTree.Renderer.GetErrorHandledTask(Task taskToHandle)

Can you debug with Visual Studio to see what is null?

This is going to should silly but hows the best way to do that?

When I run the project with VS I see the same exception in the debug console but I don't get the jumped to any location in the code.

The exception happens prior to the break-point with the 'Change'

In my opinion some of the DatePickers Value is null. Can you check that?

Thats what I initially thought but event when the event is removed it throws the exception.

Check the property bound to DatePicker Value. According to your screenshot you have:
image

This will generated @bind-Value expression - not sure why you need both Change event and @bind-Value

Okay that was the reason :+1:

The reason for it is the database type is time on during load I set a property to the correct TimeSpan that gets bound and when the user edits the time the event sets the database value to the changed TimeSpan.

Work around is to add 1 second to the initial datetime and then take it back off during the event.

On load:
Set Property mondayDT
${new DateTime() + weekbooking.Monday + new TimeSpan(0,0,1)}

Datepicker event:
${weekbooking.Monday = (event.value.TimeOfDay - new TimeSpan(0,0,1))}