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

Why does ModelType parameter require an Object and not a Type? Or can ModelType use an object that defined as an Interface?

I am displaying a grid using a collection of objects whose Type was generated at runtime. The grid has some Templated columns so I need to supply a ModelType attribute for the grid. The objects implement a statically defined interface. I have tried using an object that is typed as the Interface and an Object but I get a "System.InvalidCastException: Object must implement IConvertible." error. 

Is there a workaround for this issue? Would it be possible for ModelType to accept an actual Type instead of an object? Or perhaps the Template context can be derived from the TValue property. It seems that ModelType and TValue are somewhat redundant.

Any help would be greatly appreciated.



1 Reply

JW Jeffrey West August 29, 2019 04:59 PM UTC

Never mind. I found a workaround by using a different Type that had properties with the same names.


Live Chat Icon For mobile
Up arrow icon