We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

ColumnTemplate InvalidCastException GUID type property

Hello everyone,

I am running into an InvalidCastException when using a class with a property of type GUID. I believe that the at Syncfusion.EJ2.Blazor.BaseComponent.ChangeType method has problems converting a string value into a GUID object. 

System.InvalidCastException: Invalid cast from 'System.String' to 'System.Guid'.
   at System.Convert.DefaultToType(IConvertible value, Type targetType, IFormatProvider provider)
   at System.String.System.IConvertible.ToType(Type type, IFormatProvider provider)
   at System.Convert.ChangeType(Object value, Type conversionType, IFormatProvider provider)
   at System.Convert.ChangeType(Object value, Type conversionType)
   at Syncfusion.EJ2.Blazor.BaseComponent.ChangeType(Object value, Type conversionType)
   at Syncfusion.EJ2.Blazor.BaseComponent.GetObject(Dictionary`2 Data, Type ModelType)
   at Syncfusion.EJ2.Blazor.Grids.GridColumn.BuildRenderTree(RenderTreeBuilder builder)
   at Microsoft.AspNetCore.Components.ComponentBase.<.ctor>b__5_0(RenderTreeBuilder builder)
   at Microsoft.AspNetCore.Components.Rendering.ComponentState.RenderIntoBatch(RenderBatchBuilder batchBuilder, RenderFragment renderFragment)
   at Microsoft.AspNetCore.Components.Rendering.Renderer.RenderInExistingBatch(RenderQueueEntry renderQueueEntry)
   at Microsoft.AspNetCore.Components.Rendering.Renderer.ProcessRenderQueue()
Microsoft.AspNetCore.Routing.EndpointMiddleware: Information: Executed endpoint '/_blazor'
Microsoft.AspNetCore.Hosting.Diagnostics: Information: Request finished in 6272.542600000001ms 101 

I am trying to dynamically create the columns for the grid, as these are basically dependent on a Dictionary inside my DynamicEntity class. 
For this I do overwrite the column template, to define how the grid can access the dictionary values.

Below my code for the grid. I did include it as link to PasteBin, as I could not find anything to include code directly into the forum thread.

@code section of the component:

And within my DynamicEntity class there exists a property of type Guid. As Guid does not implement the IConvertible interface, I think here lies the problem.

Is there some kind of possibility to attach a convertor to the Grid ? The only other solution for this problem which comes to my mind would be to implement something like a custom ConvertibleGuid-Type which does implement IConvertible.

Thank you for your help.

Best Regards,


3 Replies

RS Renjith Singh Rajendran Syncfusion Team July 30, 2019 01:31 PM UTC

Hi Karl,  

We have validated the defect you have initiated with us. Thank you for taking the time to report this issue “Script error : Invalid cast from 'System.String' to 'System.Guid'.” 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 subsequent Nuget release which is expected to be roll out on or before August 19th 2019. 
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. 

Renjith Singh Rajendran. 

KP Karl Posch July 30, 2019 02:48 PM UTC

Hello Renjith,

thank you for your reply. I am looking forward for the next release. Would it be possible for me to fix this issue in the meantime by creating my own CustomGridColumn, which does derive from the Syncfusion.EJ2.Blazor.Grids.GridColumn? This class would then simply have its own ChangeType Method, which does some own conversion logic if the type happens to be a Guid. Otherwise it would call the method of the base class.

Best Regards,


VN Vignesh Natarajan Syncfusion Team July 31, 2019 11:28 AM UTC

Hi Karl,  

Thanks for your update.  

Query: “Would it be possible for me to fix this issue in the meantime by creating my own CustomGridColumn, which does derive from the Syncfusion.EJ2.Blazor.Grids.GridColumn? 

No. Because we have used Blazor’s renderFragment concept to render the templates in Blazor Grid. So while using this concept, we will serialize the model class during the rendering which will contain the GUID property and exception will occur at that time itself even if we extend and use CustomGridColumn. Hence it is not feasible to achieve through any workaround. So we appreciate your patience until then. 

We will get back to you once the reported issue is fixed.    

Vignesh Natarajan. 

Live Chat Icon For mobile
Up arrow icon