Hello,
I am not sure if I am doing something wrong because it DOES work on your demo but not on my end.
I have created a simple app to reproduce the error I am having in another app I am working on:
When I click select all from a multi-select Dropdownlist it throws the following error:
[2022-12-15T02:40:54.860Z] Error: System.InvalidCastException: Unable to cast object of type 'System.Linq.EnumerableQuery1[System.String]' to type 'System.String'. at Radzen.DropDownBase
1.SelectAll()
at Microsoft.AspNetCore.Components.ComponentBase.CallStateHasChangedOnAsyncCompletion(Task task)
at Microsoft.AspNetCore.Components.RenderTree.Renderer.GetErrorHandledTask(Task taskToHandle, ComponentState owningComponentState)
However, when I click one by one it does work as expected
I appreciate any help!
@page "/"
<PageTitle>Index</PageTitle>
<h1>Hello, world!</h1>
<RadzenDropDown AllowClear="true" AllowFiltering="true" FilterCaseSensitivity="FilterCaseSensitivity.CaseInsensitive"
Multiple="true" Placeholder="Select..." AllowSelectAll=true Data=@stringList TValue="string" />
@code
{
public string[] stringList = { "Item1", "Item2", "Item3" };
}
enchev
December 15, 2022, 7:06am
4
cscastilloliva90:
TValue="string"
This should be IEnumerable - you might need to check carefully our demos.
@enchev I tried with an IEnumerable as well and it still throwing the same error as before:
cscastilloliva90:
[2022-12-15T02:40:54.860Z] Error: System.InvalidCastException: Unable to cast object of type 'System.Linq.EnumerableQuery1[System.String]' to type 'System.String'. at Radzen.DropDownBase
1.SelectAll()
at Microsoft.AspNetCore.Components.ComponentBase.CallStateHasChangedOnAsyncCompletion(Task task)
at Microsoft.AspNetCore.Components.RenderTree.Renderer.GetErrorHandledTask(Task taskToHandle, ComponentState owningComponentState)
@page "/"
<PageTitle>Index</PageTitle>
<h1>Hello, world!</h1>
<RadzenDropDown AllowClear="true" AllowFiltering="true" FilterCaseSensitivity="FilterCaseSensitivity.CaseInsensitive"
@bind-Value=@dropdownTestsresults Multiple="true" Placeholder="Select..." Data=@data TextProperty="TextProperty" ValueProperty="ValueProperty"
Class="w-100" />
@code {
public class TestDro
{
public string TextProperty { get; set; }
public string ValueProperty { get; set; }
}
IEnumerable<TestDro> dropdownTestsresults;
public class DropDownTest
{
public string TextProperty { get; set; }
public string ValueProperty { get; set; }
}
DropDownTest[] dropDownTests = new DropDownTest[]
{
new DropDownTest(){ TextProperty="Text1", ValueProperty = "Value1"},
new DropDownTest(){ TextProperty="Text2", ValueProperty = "Value2"}
};
public IEnumerable<DropDownTest> GetAllValues()
{
return dropDownTests;
}
public IEnumerable<DropDownTest> data { get; set; }
protected override async Task OnInitializedAsync()
{
data = GetAllValues();
}
}
enchev
December 15, 2022, 4:04pm
8
cscastilloliva90:
dropdownTestsresults
Looks like you didn’t checked the demos at all. It should be IEnumerable since your ValueProperty is a string.