I am writing a Blazor app and my Razor file has a dropdown for Zip Codes. (populated from a CSV file)
Some cities share the same zip code.
Zip, City
00000, CityA
00000, CityB
When I select a city, here is my code
private void SetModel(string zipCode)
{
var places = places.FirstOrDefault(p => p.ZipCode == zipCode);
_model.City = place.City;
_model.State = place.State;
_model.ZipCode = place.ZipCode;
}
I know FirstOrDefault will always get the first item but I don't know what I should modify the code so I get the User selected item
The code in my Razor file
<RadzenDropDown Id="locations" AllowFiltering="true" LoadData="@ChangedLocation" Data="@places" TextProperty="Key" ValueProperty="ZipCode" Change="o => SetModel(o.ToString())" />