DateTimePicker: 2-Way binding not working as expected

In the attached files, there is a DataGrid that has two DateTimePickers.  2-way binding is configured, but not working correctly.  You can change the date and time values, but as soon as you click on save the modal dialog stays open and all the values in the dialog reset.

Example:

Before changing data:


Change date/time:


Click on SAVE:



Attachment: TrainingComponent.razor_548790d8.zip

7 Replies

RS Renjith Singh Rajendran Syncfusion Team August 26, 2021 02:36 PM UTC

Hi Scot, 

Greetings from Syncfusion support. 

We suggest you to ensure to use a CRUD handled OData service(as like the below documentation) to perform CRUD in a Grid bind with ODataV4Adaptor. Also we suggest you to check whether the CRUD is properly handled based on your PrimaryKey column value in OData service. Please refer the documentation below, 

If you are still facing difficulties then the following details would be helpful for us to proceed further. 

  1. Bind OnActionFailure event to grid, and share the details you get in the args of this event handler.
  2. Share a video demo showing the replication of the problem you are facing.
  3. Share the details of any exception, if any occurred in the browser console.
  4. If possible, share a simple issue reproducing sample to us to validate based on this scenario.

The provided information will help us analyze the problem, and provide you a solution as early as possible. 

Regards, 
Renjith R 



SW Scot Woodyard August 26, 2021 05:34 PM UTC


  1. OnActionEvent was implemented, but it never gets called
  2. This exception is being thrown by the ODATA API whenever I change either of the DateTime values using teh DateTimePicker:


  3. Message "One or more errors occurred. (One or more errors occurred. (Cannot convert the literal '2021-08-26T00:00:00' to the expected type 'Edm.DateTimeOffset'.))" 




RS Renjith Singh Rajendran Syncfusion Team August 30, 2021 03:38 AM UTC

Hi Scot, 

We checked your shared codes, we could see that you have repeated the SfDateTimePicker inside Template two times for the same EndDate field. We are suspecting that this might be causing problem from your side. So please check this by modifying your repeated EndDate field name to StartDate field from your side. 

<div class="form-row"> 
    <div class="form-group col-md-6"> 
        <label class="e-label-top">Start Date</label> 
        <SfDatePicker TValue="DateTime" 
                          @bind-Value="@Training.StartDate" 
                          AllowEdit="true" 
                          Format="MM/dd/yy HH:mm tt"> 
        </SfDatePicker> 
    </div> 
    <div class="form-group col-md-6"> 
        <label class="e-label-top">End Date</label> 
        <SfDateTimePicker TValue="DateTime" 
                          @bind-Value="@Training.EndDate"> 
        </SfDateTimePicker> 
    </div> 
</div> 


If you are still facing difficulties, then kindly get back to us with the complete stacktrace of the exception you are facing along with the odata controller page codes(we need to check the PATCH method codes which you have used) to proceed further. 

Regards, 
Renjith R 



SW Scot Woodyard August 30, 2021 06:03 PM UTC

Made the changes above, but that did not resolve the issue.  Blazor is expecting a  Edm.DateTimeOffset value, and the control is sending a literal DateTime value.


Here is the controller code:

[HttpPatch("Training({id})")]

public async Task UpdateTraining(Guid id, [FromBody] Delta patch)

{

if (!ModelState.IsValid)

{

return BadRequest(ModelState);

}


var training = await _itssMasterContext

.Training

.FirstOrDefaultAsync(e => e.Id == id

);


if (training == null)

{

return NotFound();

}


patch.Patch(training);

await _itssMasterContext.SaveChangesAsync();


return NoContent();

}


The exception gets thrown here:


if (!ModelState.IsValid)

{

return BadRequest(ModelState);

}


The Exception is:

One or more errors occurred. (One or more errors occurred. (Cannot convert the literal '2021-08-30T09:10:00' to the expected type 'Edm.DateTimeOffset'.))


Stack trace:

at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()

at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)

at Microsoft.AspNetCore.OData.Formatter.Wrapper.ODataReaderExtensions.d__1.MoveNext()

at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()

at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)

at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)

at System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1.ConfiguredTaskAwaiter.GetResult()

at Microsoft.AspNetCore.OData.Formatter.Deserialization.ODataResourceDeserializer.d__1.MoveNext()

at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()

at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)

at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)

at System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1.ConfiguredTaskAwaiter.GetResult()

at Microsoft.AspNetCore.OData.Formatter.ODataInputFormatter.d__10.MoveNext()

at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()

at Microsoft.AspNetCore.OData.Formatter.ODataInputFormatter.LoggerError(HttpContext context, Exception ex)

at Microsoft.AspNetCore.OData.Formatter.ODataInputFormatter.d__10.MoveNext()

at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()

at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)

at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)

at Microsoft.AspNetCore.OData.Formatter.ODataInputFormatter.d__8.MoveNext()



RS Renjith Singh Rajendran Syncfusion Team August 31, 2021 12:18 PM UTC

Hi Scot, 

We have validated the reported problem from our side and forwarded to the corresponding development team for further analysis. We will update you further details on September 2, 2021. 

Until then we appreciate your patience. 

Regards, 
Renjith R 



RS Renjith Singh Rajendran Syncfusion Team September 2, 2021 05:53 AM UTC

Hi Scot, 

We have confirmed it as a bug and logged the defect report DateTimeKind is always set to Unspecified in DateTimePicker’s value” for the same. Thank you for taking the time to report this issue and helping us improve our product. At Syncfusion, we are committed to fixing all validated defects (subject to technological feasibility and Product Development Life Cycle) and including the defect fix in our weekly release which is expected to be rolled out by the mid of September, 2021.  
       
You can now track the current status of your request, review the proposed resolution timeline, and contact us for any further inquiries through this link.       

Please follow up on above link for future updates regarding this issue. 

Regards, 
Renjith R 



RS Renjith Singh Rajendran Syncfusion Team September 20, 2021 08:57 AM UTC

Hi Scot, 

We are glad to announce that our weekly release v19.2.0.62 
is rolled out, which includes the fix for the reported issue ‘DateTimeKind is always set to Unspecified in DateTimePicker’s value’. So kindly upgrade to the latest version to avail the fix. 
 
 
We thank you for your support and appreciate your patience in waiting for this release. Please get in touch with us if you would require any further assistance. 
 
Regards, 
Renjith R 
 


Loader.
Up arrow icon