Could not convert string to DateTime

Hello SyncFusion

I trust you are well.

I have a little issue with the Grid - it contains a date column as follows

  <GridColumn Field=@nameof(ResourceForGridDTO.ResourceDate) HeaderText="Resource Date" EditType="EditType.DatePickerEdit" Width="120" Format="d" Type="ColumnType.Date"></GridColumn>

Initially the ResourceDate is 01/01/0001 as per design, the value for this field is entered later, which brings me to my issue: When I edit it, or rather, try to edit it an error appears in VS 

Newtonsoft.Json.JsonReaderException: Could not convert string to DateTime: 0000-12-31T23:50:39.000Z. Path 'rowData.ResourceDate', line 1, position 257.
   at Newtonsoft.Json.JsonReader.ReadDateTimeString(String s)
   at Newtonsoft.Json.JsonTextReader.FinishReadQuotedStringValue(ReadType readType)
   at Newtonsoft.Json.JsonTextReader.ReadAsDateTime()
   at Newtonsoft.Json.JsonReader.ReadForType(JsonContract contract, Boolean hasConverter)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateObject(Object newObject, JsonReader reader, JsonObjectContract contract, JsonProperty member, String id)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateObject(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.SetPropertyValue(JsonProperty property, JsonConverter propertyConverter, JsonContainerContract containerContract, JsonProperty containerProperty, JsonReader reader, Object target)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateObject(Object newObject, JsonReader reader, JsonObjectContract contract, JsonProperty member, String id)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateObject(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Deserialize(JsonReader reader, Type objectType, Boolean checkAdditionalContent)
   at Newtonsoft.Json.JsonSerializer.DeserializeInternal(JsonReader reader, Type objectType)
   at Newtonsoft.Json.JsonSerializer.Deserialize(JsonReader reader, Type objectType)
   at Newtonsoft.Json.JsonConvert.DeserializeObject(String value, Type type, JsonSerializerSettings settings)
   at Syncfusion.Blazor.BaseComponent.Trigger(String eventName, String arg)
Error: Newtonsoft.Json.JsonReaderException: Could not convert string to DateTime: 0000-12-31T23:50:39.000Z. Path 'rowData.ResourceDate', line 1, position 257.
   at Newtonsoft.Json.JsonReader.ReadDateTimeString(String s)
   at Newtonsoft.Json.JsonTextReader.FinishReadQuotedStringValue(ReadType readType)
   at Newtonsoft.Json.JsonTextReader.ReadAsDateTime()
   at Newtonsoft.Json.JsonReader.ReadForType(JsonContract contract, Boolean hasConverter)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateObject(Object newObject, JsonReader reader, JsonObjectContract contract, JsonProperty member, String id)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateObject(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.SetPropertyValue(JsonProperty property, JsonConverter propertyConverter, JsonContainerContract containerContract, JsonProperty containerProperty, JsonReader reader, Object target)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateObject(Object newObject, JsonReader reader, JsonObjectContract contract, JsonProperty member, String id)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateObject(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Deserialize(JsonReader reader, Type objectType, Boolean checkAdditionalContent)
   at Newtonsoft.Json.JsonSerializer.DeserializeInternal(JsonReader reader, Type objectType)
   at Newtonsoft.Json.JsonSerializer.Deserialize(JsonReader reader, Type objectType)
   at Newtonsoft.Json.JsonConvert.DeserializeObject(String value, Type type, JsonSerializerSettings settings)
   at Syncfusion.Blazor.BaseComponent.Trigger(String eventName, String arg)
    at Object.endInvokeDotNetFromJS (https://localhost:44328/_framework/blazor.server.js:8:31660)
    at e.<anonymous> (https://localhost:44328/_framework/blazor.server.js:8:103446)
    at https://localhost:44328/_framework/blazor.server.js:1:19202
    at Array.forEach (<anonymous>)
    at e.invokeClientMethod (https://localhost:44328/_framework/blazor.server.js:1:19173)
    at e.processIncomingData (https://localhost:44328/_framework/blazor.server.js:1:17165)
    at e.connection.onreceive (https://localhost:44328/_framework/blazor.server.js:1:10276)
    at WebSocket.i.onmessage (https://localhost:44328/_framework/blazor.server.js:1:38091)

And the app stops.

Entering a date manually in the database and editing will work.




4 Replies 1 reply marked as answer

VN Vignesh Natarajan Syncfusion Team June 10, 2020 10:36 AM UTC

Hi John,  
 
Thanks for contacting Syncfusion support.  
 
Query: “I have a little issue with the Grid - it contains a date column as follows 
 
From your query we understand that you are facing issue while editing a record with datetime value. We suspect that you have defined the ResourceDate property as DateTime in your model class. To resolve the issue, kindly define the type of ResourceDate as DateTime? (nullable datetime) in your model class (ResourceForGridDTO).  
 
public class ResourceForGridDTO 
  { 
      public int OrderID { getset; } 
      public string CustomerID { getset; } 
      public DateTime? ResourceDate { getset; } 
      public double Freight { getset; } 
  }  
 
 
If you are still facing the issue or above solution does not resolve your query. Kindly share the following details about your issue.  
 
  1. Share the Grid rendering code example.
  2. Are you facing the reported issue while saving the changes or while clicking the record for editing?
  3. Kindly share your timezone.
  4. Share the type of your edit mode, dialog editing or batch editing or normal editing.
  5. Share the video demonstration of the reported issue.
  6. Share your Syncfusion Nuget package version.
 
Requested details will be helpful for us to validate the reported issue at our end and provide solution as soon as possible.   
 
Regards, 
Vignesh Natarajan 



JO John June 11, 2020 12:30 PM UTC

Hi, thank you foe your response.
I attempted this a few days ago but changing it to null does not work.
I will answer your questions accordingly

Share the Grid rendering code example.
Attached
Are you facing the reported issue while saving the changes or while clicking the record for editing?
Clicking the record for editing, I can go no further with the app at this point so I never get to save.
Kindly share your timezone.
CET
Share the type of your edit mode, dialog editing or batch editing or normal editing.
Any mode
Share the video demonstration of the reported issue. 
Attached
Share your Syncfusion Nuget package version
18.1.0.56

Attachment: ForSyncFusion_ba1c0f2a.zip


JO John June 12, 2020 11:48 AM UTC

Hi again

I am working on the DELETE function for this grid and I want to add to this that the error also happens when I attempt to delete a row with this date format.


Attachment: forsyncfusion2_584f927.zip


VN Vignesh Natarajan Syncfusion Team June 15, 2020 11:28 AM UTC

Hi John,  
 
Thanks for sharing the requested details. 
 
Query: Could not convert string to DateTime 
 
We have validated the defect you have initiated with us and confirmed it is a bug. We have already logged an bug related to time zone “Timezone issue occurs while updating datetime column in grid blazor component”. We will consider your scenario also while fixing that issue. 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 2020 Volume 2 release which is expected to be rolled out in the month end of June 2020. 
 
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. 
 
 
Till then we appreciate your patience.  
 
Regards, 
Vignesh Natarajan 
 
 


Marked as answer
Loader.
Up arrow icon