I have a number of inputselects that have options that are amended from other data on the screen. The selected item is never removed. However it seems that the list retains the selectedIndex and displays the item in that position, rather than the correct bound data. The options are updated correctly.An example of the code is:
<select class="form-control form-select input" name="personnel-value" id="personnel-value" @bind:get="@(StaffNo)" @bind:set="UpdateStaffNoAsync"><option value="">Select</option> @foreach (PersonnelModel personnel in PersonnelOptions) {<option value="@personnel.StaffNo">@personnel.DisplayName</option> }</select>where PersonnelOptions returns a alphanumerically ordered list that is dynamically amended by other routines.
Everything works fine until the options are changed due to the list returned by PersonnelOptions changing.
If the list initially contains the values:Select300
and I select 300 (index 1) everything is ok.If '100' is then added to the list dynamically then '100' is then displayed (index 1) instead of '300'.if '500' is then added the item at index 1 is still displayed i.e. '100'.If '100'is removed then index 1 is still displayed, now the correct value of '300'.