Blazor.radzen.com templateform exception

The templateform example fails when changing the country in the billing address tab:

Error: System.InvalidCastException: Unable to cast object of type 'System.Int32' to type 'System.String'.
   at Radzen.DropDownBase`1.SelectItem(Object item, Boolean raiseChange)
   at Radzen.Blazor.RadzenDropDown`1.<>c__DisplayClass0_0.<BuildRenderTree>b__9()
   at Microsoft.AspNetCore.Components.EventCallbackWorkItem.InvokeAsync[T](MulticastDelegate delegate, T arg)
   at Microsoft.AspNetCore.Components.EventCallbackWorkItem.InvokeAsync(Object arg)
   at Microsoft.AspNetCore.Components.ComponentBase.Microsoft.AspNetCore.Components.IHandleEvent.HandleEventAsync(EventCallbackWorkItem callback, Object arg)
   at Microsoft.AspNetCore.Components.EventCallback.InvokeAsync(Object arg)
   at Microsoft.AspNetCore.Components.RenderTree.Renderer.DispatchEventAsync(UInt64 eventHandlerId, EventFieldInfo fieldInfo, EventArgs eventArgs)

BTW, it is very strange to see a form example without any validation. Also, the form components do not generate any validation styles and validation isn't triggered until the template form submission. This is an important weakness IMHO as nowadays people expect some realtime feedback when chaning form fields like:

expected%20validation

Demo fixed - we will update the example soon with validation.

Also, the form components do not generate any validation styles and validation isn't triggered until the template form submission. This is an important weakness IMHO as nowadays people expect some realtime feedback

I just tested and it seems this is how the default Blazor validation works by default. It triggers on form submission. You can suggest this as an improvement in the ASP.NET github repo.

From ASP.NET Core Blazor forms and validation:

Inputs are validated when they're changed and when a form is submitted.
[...]
Blazor performs two types of validation:

  • Field validation is performed when the user tabs out of a field. During field validation, the DataAnnotationsValidator component associates all reported validation results with the field.
  • Model validation is performed when the user submits the form. During model validation, the DataAnnotationsValidator component attempts to determine the field based on the member name that the validation result reports. Validation results that aren't associated with an individual member are associated with the model rather than a field.

I stand corrected. There is indeed validation on change (not on blur as I was testing which is a subtle but important difference).

We need to overhaul the way validation works in Radzen components and provide better integration - validation on change, valid/invalid states (which kind of almost works at the moment). I will update this thread once there is progress.

Those are very good news!