Binding the value to a nullable enum throws an exception
Hello,
Initial I want no item to be selected to let the user select a value. I thought it would be enough if my bindvalue would be of a nullable type. I'm getting an exception when trying. If this is not supported, how can I do it?
protected class ReleaseTypeFilterModel { public SessionState.ReleaseType ReleaseType { get; set; } public string DisplayText { get { return ReleaseType.ToString(); } } }
An unhandled exception occurred while processing the request.
InvalidOperationException: Telerik.Blazor.Components.TelerikDropDownList`2[ReleaseCalendar.Pages.IndexBase+ReleaseTypeFilterModel,System.Nullable`1[ReleaseCalendar.SessionState.ReleaseType]] does not support the type 'System.Nullable`1[ReleaseCalendar.SessionState.ReleaseType]'.
Telerik.Blazor.Components.Common.TelerikSelectBase<TItem, TValue>.TryParseValueFromString(string value, out TValue result, out string validationErrorMessage)
Telerik.Blazor.Components.Common.TelerikSelectBase<TItem, TValue>.TryParseValueFromString(string value, out TValue result, out string validationErrorMessage)
Microsoft.AspNetCore.Components.RenderTree.RenderTreeDiffBuilder.InitializeNewComponentFrame(ref DiffContext diffContext, int frameIndex)
Microsoft.AspNetCore.Components.RenderTree.RenderTreeDiffBuilder.InitializeNewSubtree(ref DiffContext diffContext, int frameIndex)
Microsoft.AspNetCore.Components.RenderTree.RenderTreeDiffBuilder.InsertNewFrame(ref DiffContext diffContext, int newFrameIndex)
Microsoft.AspNetCore.Components.RenderTree.RenderTreeDiffBuilder.AppendDiffEntriesForRange(ref DiffContext diffContext, int oldStartIndex, int oldEndIndexExcl, int newStartIndex, int newEndIndexExcl)
Microsoft.AspNetCore.Components.RenderTree.RenderTreeDiffBuilder.ComputeDiff(Renderer renderer, RenderBatchBuilder batchBuilder, int componentId, ArrayRange<RenderTreeFrame> oldTree, ArrayRange<RenderTreeFrame> newTree)
Microsoft.AspNetCore.Razor.Runtime.TagHelpers.TagHelperRunner.<RunAsync>g__Awaited|0_0(Task task, TagHelperExecutionContext executionContext, int i, int count)
I am attaching here two examples that showcase how this should work after it gets fixed (disclaimer - if the investigation points to something more complex, this may have to change). There are a few differences from the original samples that were provided, mostly in the way the value is bound (it needs to be a reference field, in this snippet it isn't, unless there is more pertinent code I'm missing).
On a side note - you don't really need the component reference, the label won't attach to it. The reference is just a memory pointer, it does not render as an id attribute. For the time being, you can wrap the entire component in the <label> tag.