0
<select class="dropdown" @onchange="update" id="selectMe">
    @for (int i = 0; i < my_List.Count; i++)
    {
        <option value="@i">@my_List[i]</option>
    }
</select>
<br>
<br>
@my_index
@code{
    int my_index;
    void update()
    {
        my_index = ......(?)
    }
}

I want to access the index of the dropdownlist. Any help is appreciated.

user1448393
  • 105
  • 1
  • 11
  • Adjust your thinking about Blazor; we tend to bind inputs' values to variables so that the variables have the value we want when we take an action. More involved components such as an InputSelect will have a Value property and ValueChanged, and these can either be set independently (you can write some custom code in valueChanged that does stuff) or you just @bind-Value="name of some field or prop here" and the compiler will create a valueChanged for you that updates the field/prop. See https://stackoverflow.com/questions/60658450/when-to-use-valuechanged-and-valueexpression-in-blazor for more – Caius Jard Jan 05 '22 at 07:26

0 Answers0