I get the following error when navigating to a new page from a page with a bound conrol:
Microsoft.AspNetCore.Components.WebAssembly.Rendering.WebAssemblyRenderer[100] Unhandled exception rendering component: Object reference not set to an instance of an object.System.NullReferenceException: Object reference not set to an instance of an object.The same error also occurs if I update the search text box too quickly. The search function is executed with async IHttpClientFactory currently. If I don't set the list to null it doesn't display the updated results correctly but I believe this is also a problem.
Thoughts?
Razor Page
<SfTextBox Paceholder="Recipe Filter" Width="250px" @oninput="OnChange"></SfTextBox><SfListView TValue="clRecipe" DataSource="@recipeFiltered"><ListViewEvents TValue="clRecipe" Clicked="Click"></ListViewEvents><ListViewFieldSettings Id="RecipeID" Text="RecipeName" TValue="clRecipe" /></SfListView>private async Task OnChange(Microsoft.AspNetCore.Components.ChangeEventArgs e){ string str = e.Value.ToString(); recipeFiltered = null; recipeFiltered = await RecipeService.getRecipeListNameFilter(str);}Update
trying to ensure that the list is never null breaks the control. Currently the control never updates. I dont see how the referenced page solution solves the issue.
recipeFiltered.Add(new clRecipe());foreach ( clRecipe rep in await RecipeService.getRecipeListNameFilter(str)){ recipeFiltered.Add(rep);}Updating the page code to remove the control when the list is null seems to be on the right track but still errors randomly and when changing pages.
@if (recipeFiltered is not null){<SfListView TValue="clRecipe" DataSource="@recipeFiltered"><ListViewEvents TValue="clRecipe" Clicked="Click"></ListViewEvents><ListViewFieldSettings Id="RecipeID" Text="RecipeName" TValue="clRecipe" /></SfListView>}