Quantcast
Channel: Active questions tagged blazor - Stack Overflow
Viewing all articles
Browse latest Browse all 4839

inputselect in Blazor 8

$
0
0

I'm learning Blazor 8 and facing an issue:I have a list of persons. the Person object has an id, a name and an age. I would like to use two dropdown buttons to display or control each other. After selected a name, the age dropdown should display the age of the selected person's name and vise versa.I don't want to use JSRuntime.

Thanks for your help

with the following code I am able to get the age after selecting the name and vise versa. But I'm not able to set them in the dropdown button:

@inject PersonContext DB<div class="mb-3"><label for="pAge" class="form-label">Age:</label><InputSelect @bind-Value="selectedAge">                          <option value="">select an age...</option>        @foreach (var pers in DB.Persons)        {<option value="@pers.Name">                @pers.Age</option>        }</InputSelect></div>  <div class="mb-3"><label for="pName" class="form-label">name:</label> <InputSelect @bind-Value="selectedName"><option value="">select a name...</option>        @foreach (var pers in DB.Persons)        {<option value="@pers.Age">                @pers.Name</option>        }</InputSelect></div>  @code {    public string? selectedName { get; set; } = string.Empty;    public string? selectedAge { get; set; } = string.Empty;}

Viewing all articles
Browse latest Browse all 4839

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>