Error of casting in SelectItem Method on DropDownBase class

I'm getting an error when I click on an item in the DropDownDataGrid.

The error is: System.InvalidCastException: Unable to cast object of type 'System.Int32' to type 'Modelo.PesadaEntrada'

The stck trace is:
at **Radzen.DropDownBase1.SelectItem**(Object item, Boolean raiseChange) at Radzen.Blazor.RadzenDropDownDataGrid1.OnRowSelect(Object item)
at Microsoft.AspNetCore.Components.ComponentBase.CallStateHasChangedOnAsyncCompletion(Task task)
at Radzen.Blazor.RadzenDataGrid1.OnRowSelect(TItem item, Boolean raiseChange) at Radzen.Blazor.RadzenDataGrid1.OnRowClick(DataGridRowMouseEventArgs1 args) at Radzen.Blazor.RadzenDataGridCell1.OnClick(MouseEventArgs args)
at Microsoft.AspNetCore.Components.ComponentBase.CallStateHasChangedOnAsyncCompletion(Task task)
at Microsoft.AspNetCore.Components.RenderTree.Renderer.GetErrorHandledTask(Task taskToHandle, ComponentState owningComponentState)

The error is thrown in the line:
await ValueChanged.InvokeAsync(object.Equals(internalValue, null) ? default(T) : (T)internalValue)
because of internalValue is an int and T is 'PesadaEntrada'

how can I change the Value of the internalValue to set a 'PesadaEntrada' or a null Value???

Thanks in advance

Most probably you have @bind-Value to some int property however you've missed to define ValueProperty for the DropDown (which also need to point to a property with integer values). Check our demos for reference on various DropDown configurations.

Hi,

In my case, I discovered that I would get the reported error if I had a mismatch in the upper / lower case of the ValueProperty.

For example, my value property was:

CustomerId

But the property in my class was actually:

CustomerID

(capital D).

The compiler would not flag it as an error, but Radzen would trigger the error message described in the original post.

I'm guessing it's doing a case sensitive match, and if it fails, it goes up a level to use the entire object as the selected value.

Hope that helps!

Mike