In Blazor / C# / ASP.NET Core 8.0, I am trying to load the InputSelect with the list when it is clicked, but I am not able to do it.
Actually I want to make something like multiple InputSelects. Let's say venues.
And if one item is selected in one InputSelect, I want it not to appear in other InputSelects - is this even possible?
I am using .NET 8.0 and it is a Blazor Server project.
@rendermode InteractiveServer
<div>
<InputSelect @bind-Value=SelectedVenue style="width:100px" @onfocus="LoadVenuesOnClick">
@foreach (var venue in venueNames)
{
<option value="@venue">@venue</option>
}
</InputSelect>
</div>
private void LoadVenuesOnClick()
{
List<string> venueNames = venueDL_GLOBAL.GetAvailableVenues(Hour, Day, MainHall);
if (venueNames!=null)
this.venueNames.AddRange(venueNames);
}
private List<string> venueNames = new() { "None" };
private string SelectedVenue = "None";
I have tried to do with @onselect, but it is not working:
<InputSelect @bind-Value=SelectedVenue style="width:100px" @onselect="LoadVenuesOnClick">
Also I did tried to add StateHasChanged(); to notify Blazor to re-render the component, in the LoadVenuesOnClick() function.