Hi Radzen team.
I copied/pasted the code from your example. The only modification is that I hard-code a list of data that I bind to the DropDown, instead of getting the data from a database. Everything works as expected, except when I choose an option from the DropDown, the app crashes. The following is the code I use:
@page "/"
<RadzenStack Orientation="Orientation.Horizontal" AlignItems="AlignItems.Center" JustifyContent="JustifyContent.Center"
Gap="0.5rem" class="rz-p-sm-12">
<RadzenLabel Text="Select Value" Component="DropDownFiltering" />
<RadzenDropDown @ref=@radzenDropDown @bind-SearchText=SearchText FilterCaseSensitivity="FilterCaseSensitivity.CaseInsensitive"
FilterOperator="StringFilterOperator.StartsWith" AllowFiltering="true"
Data=@locations TextProperty="@nameof(Location.Name)" ValueProperty="@nameof(Location.ID)"
AllowClear="true" @bind-Value=value Style="width: 100%; max-width: 400px;" Name="DropDownFiltering" />
</RadzenStack>
<div class="rz-p-sm-3 rz-text-align-start">
<RadzenLabel Text="@searchTextStatus" />
</div>
@code {
struct Location
{
public int ID;
public string Name;
}
RadzenDropDown<string> radzenDropDown;
IEnumerable<Location> locations;
string value;
string searchTextStatus;
protected override async Task OnInitializedAsync()
{
await base.OnInitializedAsync();
locations = new List<Location>() { new Location() { ID = 0, Name = "Location 1" }, new Location() { ID = 1, Name = "Location 2" } };
searchTextStatus = $"Search text: {searchText}";
}
string searchText = "al";
public string SearchText
{
get
{
return searchText;
}
set
{
if (searchText != value)
{
searchText = value;
searchTextStatus = $"Search text: {searchText}";
Console.WriteLine($"Search text: {radzenDropDown.SearchText}");
}
}
}
}
When selecting any option, I get an exception:
Thank you,
Riaan.