title: Blazor select dropdown set active value by code
body: <p>I am dynamicaly filling the values of a dropdown list based of the content of a List. when a item in the dropdown is selected an option to remove this item is shown. When the item is removed, it is first removed from the list and then the dropdown list is rebuilt, this is where I run in to problems. Instead of returning the dropdown to its default value when it is rebuilt the value just below the removed one is shown as selected <em>(this happens whitout the @onchange value being triggered)</em>. How can i make the dropdown list return to its default value when it is being rebuilt?</p>
  
  <p>here is some code, Razor code:</p>
  
  <pre><code>&lt;select class="form-control" @onchange="selectedValue"&gt;
     &lt;option value=""&gt;select one&lt;/option&gt;
     @foreach (var mod in values)
     {
          &lt;option value="@mod.Id"&gt;@mod.Name&lt;/option&gt;
     }
  &lt;/select&gt;
  </code></pre>
  
  <p>the class named Items that is populationg the list:</p>
  
  <pre><code>public class Items
  {
      public string Name { get; set; }
      public int Id { get; set; }
      public Items(string name, int id)
      {
          Name = name;
          Id = id;
      }
  }
  </code></pre>
  
  <p>the list itself (before it is populated):</p>
  
  <pre><code>public List&lt;Items&gt; itm = new List&lt;Items&gt;();
  </code></pre>
  
  <p>the function thats called onchange:</p>
  
  <pre><code>public string SelectedValue = "";
  public void selectedValue(ChangeEventArgs selectEvent)
  {
      SelectedValue = selectEvent.Value.ToString();
  }
  </code></pre>
  
  <p>so to sum it up, this is what's happening:</p>
  
  <ol>
  <li><p>the list is pupolated with Items.</p></li>
  <li><p>the <em>select</em> list is built of the items in the list using a @foreach loop <em>(se razor code)</em>.</p></li>
  <li><p>an item is selected from the dropdown, this runs the <em>selectedValue()</em> function and changes the value ud the SelectedValue string.</p></li>
  <li><p>the selected item is deleted from the list of items</p></li>
  <li><p>the dropdown is rebuilt using the modefied list</p></li>
  <li><p>the selected item is now set to the one directly below the deleted item, this is happening without onchange being run. this is the problem</p></li>
  <li><p>Now the selected value of the dropdown don't correspond to the one of the SelectedValue string.</p></li>
  </ol>
  
  <p>this can probably be solved by setting the  element to its default option/value, but i can't figure out how to do this.</p>
  
  <p>How can I change the selected value to be the default option <em>(in my case the "select one" option with value "")</em> of my dropdown list?</p>