Hello all,
I have a scenario I'm not sure how to solve while creating a loop of RadzenDropDown components. When trying to use @bind-Value with a loop, all of the drop downs get assigned the same variable and when you change selections in one drop down, it changes the others. Is there a way to solve this in a loop? Using the Change event would seem to be the next best option, but I don't understand how to pass the ValueProperty to that event.
@foreach (var dataFilter in DataFilterList)
{
<div class="col-lg-2">
<RadzenDropDown
TValue="IEnumerable<int>"
id=@dataFilter.FilterId
AllowClear="true"
Multiple="true"
Placeholder=@dataFilter.FilterName
Data=@dataFilter.FilterItemList
TextProperty="Description"
ValueProperty="FilterValueID"
Change="@(args => OnChange(args, dataFilter.FilterId))"
Class="w-100"
/>
</div>
}
Attempting to use the method in the example:
void OnChange(object value, int FilterValueID)
{
var str = value is IEnumerable<object> ? string.Join(", ", (IEnumerable<object>)value) : value;
Log.Information($"Value changed to {str}");
}
Results in this output:
System.Linq.Enumerable+SelectListIterator`2[System.Object,System.Object].Cast()
I'm sure I'm doing something incorrect, and any assistance would be greatly appreciated! Please let me know if you need any additional information!