Blazor - How to retrieve selected value of a Select control? RRS feed

  • Question

  • User-916945938 posted

    I have a razor component where I have two Select controls and a button. I would like to move users from one Select box to the other on button click event. How can I retrieve the selected value of first Select control? What is the industry standard way to accomplish this? I think I need to bind a property to selected value of the Select control but how can I do that? Any code examples?

    <select class="form-control" size="10" onchange="PendingUser">
         @foreach (var theUser in PendingUsers)
           <option value="@theUser">@theUser.FullName</option>
    <button type="button" class="btn btn-light" onclick="CopyToFinalized">COPY</button>
    <select class="form-control" size="10">
         @foreach (var theUser in FinalizedUsers)
            <option value="@theUser">@theUser.FullName</option>


    Wednesday, August 14, 2019 6:39 PM


  • User711641945 posted

    Hi hokn,

    If you want to get the selected value, you could use @bind like below:

    <select class="form-control" size="10" @bind="selectedValue">

    Best Regards,


    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, August 15, 2019 8:39 AM