I'm new to Blazor and I want to use the Multiple Select Dropdown - I can get the dropdown to load but as soon as I select an item I get " An unhandled exception has occurred. See browser dev tools for details." message
Detailed:
System.InvalidCastException: Unable to cast object of type 'System.Linq.EnumerableQuery1[System.Nullable1[System.Int32]]' to type 'System.Collections.Generic.IEnumerable1[System.String]'. at Radzen.DropDownBase1.SelectItem(Object item, Boolean raiseChange)
at Radzen.Blazor.RadzenDropDown`1.OnSelectItem(Object item)
at Microsoft.AspNetCore.Components.ComponentBase.CallStateHasChangedOnAsyncCompletion(Task task)
at Microsoft.AspNetCore.Components.RenderTree.Renderer.GetErrorHandledTask(Task taskToHandle)
I've tried setting the TValue but still having issues.
If I change to IEnumerable or just int - which matches the value type - I get the compile error: Severity Code Description Project File Line Suppression State
Error CS1662 Cannot convert lambda expression to intended delegate type because some of the return types in the block are not implicitly convertible to the delegate return type web_pineview C:\Pineview\PineviewERPDevelopmentRepo\web_pineview\obj\Debug\netcoreapp3.1\Razor\Pages\Index.razor.g.cs 234 Active
I did change the value to dealername which is a string to: <RadzenDropDown TValue="IEnumerable " Multiple="true" Placeholder="Select..." @bind-Value="multipleValues" Data="@Dealers" TextProperty="Dealername" ValueProperty="Dealerid" Change="@(args => Change(args, "DropDown with multiple selection"))" />
same result - control loads but as soon as I click on an item > An unhandled exception has occurred. See browser dev tools for details
Ok - I did a clean and rebuild and it works if I use the text value (dealername) - the issue is I need the dealerid which is an int - its an int in the database and model - do you know how I might cast or convert so the value is an int?
Again, the property multipleValues should be IEnumerable of your ValueProperty type. If the ValueProperty is int you will need to declare multipleValues to be IEnumerable<int>:
I have continued to try and resolve with no real resolve, I have tried different controls and found the RadzenDropDownDatagrid with multiple select works as expected, however, the RadzenListbox control with multiple select has the same issue.
public class DTOSurvey
{
public int Id { get; set; }
public string SurveyName { get; set; }
public DateTime DateCreated { get; set; }
public DateTime? DateUpdated { get; set; }
public int UserId { get; set; }
public List<DTOSurveyItem> SurveyItem { get; set; }
}
public class DTOSurveyItem
{
public int Id { get; set; }
public string ItemLabel { get; set; }
public string ItemType { get; set; }
public string ItemValue { get; set; }
public int Position { get; set; }
public int Required { get; set; }
public int? SurveyChoiceId { get; set; }
public string AnswerValueString { get; set; }
public IEnumerable<string> AnswerValueList { get; set; }
public DateTime? AnswerValueDateTime { get; set; }
public List<DTOSurveyItemOption> SurveyItemOption { get; set; }
}
public partial class DTOSurveyItemOption
{
public int Id { get; set; }
public string OptionLabel { get; set; }
}
<RadzenDropDown Name="@SurveyItem.Id.ToString()"
TValue="IEnumerable<string>"
Multiple="true"
AllowClear="true"
AllowFiltering="true"
@bind-Value="SurveyItem.AnswerValueList"
Placeholder="Select..."
Data="@SurveyItem.SurveyItemOption"
TextProperty="OptionLabel"
ValueProperty="OptionLabel"
Style="width:400px;" />
I see that this problem in not solved yet.
I'm having the same kind of problem. I have a listboxmultiselection and i want to bring the chosen option (string Name of object) in a textarea. But i'm not succeding in doing that. Can you help me out please?
Error: System.InvalidCastException: Unable to cast object of type 'System.Linq.EnumerableQuery1[System.Int32]' to type 'System.Collections.Generic.IEnumerable1[System.String]'.
at Radzen.DropDownBase`1.SelectItem(Object item, Boolean raiseChange)
at Radzen.Blazor.RadzenListBox`1.<>c__DisplayClass0_0.<b__6>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---