Checking box on multiselect Listbox throws exception

Using this code:

@page "/search"
@using Radzen.Blazor
@using IssueTracker2.Business
@using IssueTracker2CommonDataStructures
@inject StatusService statusService

Search

@code {
protected List Statuses;

protected override async Task OnInitializedAsync()
{
    // Filling The look-ups
    Statuses = await statusService.GetStatusesAsync();
} 

}

when I click on a checkbox on an item row in a multiselect Listbox, chrome throws this error:

blazor.server.js:1 [2020-04-13T14:31:12.082Z] Information: Normalizing '_blazor' to 'https://localhost:44363/_blazor'.
blazor.server.js:1 [2020-04-13T14:31:12.233Z] Information: WebSocket connected to wss://localhost:44363/_blazor?id=enkev-LRCUfp7EmyoePTFQ.
blazor.server.js:15 [2020-04-13T14:31:16.294Z] Error: System.InvalidCastException: Unable to cast object of type 'System.Linq.EnumerableQuery1[System.Int32]' to type 'System.Int32'. at Radzen.DropDownBase1.SelectItem(Object item, Boolean raiseChange)
at Radzen.Blazor.RadzenListBox`1.<>c__DisplayClass0_0.<b__3>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at Microsoft.AspNetCore.Components.ComponentBase.CallStateHasChangedOnAsyncCompletion(Task task)
at Microsoft.AspNetCore.Components.RenderTree.Renderer.GetErrorHandledTask(Task taskToHandle)
e.log @ blazor.server.js:15
blazor.server.js:1 [2020-04-13T14:31:16.295Z] Information: Connection disconnected.

The Status Class looks like this:

namespace IssueTracker2CommonDataStructures
{
using System;
using System.Collections.Generic;
public partial class Status
{
public int Id { get; set; }
public string Name { get; set; }
public int SortSequence { get; set; }
public string Style { get; set; }
public int StatusDefault { get; set; }
public Nullable ExternalOnly { get; set; }
public Nullable IsTerminal { get; set; }
}
}

Any suggestions? Anything more you'd like to see? I can send you the entire solution if that would help.

What’s the TValue of the ListBox?

Hmm, not quite sure why it didn't paste in the RadzenListBox. :confused: Not too easy to figure out what I'm saying without that. :open_mouth: Lemme try a picture:

You should set TValue to IEnumerable<int> when you have multiple selection.

Works like a charm! Thank you very much. :slight_smile:

This forum uses markdown similar to Stackoverflow. If you want to paste code you must embed it in a ``` block.