title: Select Box Not Populated On View After Model State Is Invalid
body: <p>I'm creating a new .net core MVC project for people to use to submit proposals for presentation at a conference.</p>
  
  <p>For the proposal submission form I'm using a binding model (AKA view model) to bind the user's input on the form.</p>
  
  <p>Here is part of the code for the binding model class:</p>
  
  <pre><code>public class BaseSubmissionBindingModel
  {
  
      public BaseSubmissionBindingModel(){
  
      }
  
      [Required]
      public int ConferenceId { get; set; }
  
      [Required]
      [StringLength(250)]
      [Display(Name = "Title")]
      public string SubmissionTitle { get; set; }
  
      [Required]
      [StringLength(1000)]
      [Display(Name = "Abstract")]
      public string SubmissionAbstract { get; set; }
  
  
      public IEnumerable&lt;SelectListItem&gt; SubmissionCategoryItems { get; set; }
  
      [Required]
      [Display(Name = "Select the Submission Category ")]
      public string SelectedSubmissionCategory { get; set; }
  
  }
  </code></pre>
  
  <p>Note the field SubmissionCategoryItems - this field is used to populate a drop down select form control in the view.  The data for this control comes from a database query and which submission categories to show depends on the conference id value.</p>
  
  <p>In the controller class I get the submission categories for the conference id and create a <code>List&lt;SelectListItem&gt; submissionCategoryItems</code> with an SelectListItem object for each submission category. </p>
  
  <p>I then create the BaseSubmissionBindingModel object and assign the submissionCategoryItems to the <code>BaseSubmissionBindingModel IEnumerable&lt;SelectListItem&gt; SubmissionCategoryItems</code>.</p>
  
  <p>The controller then returns View(baseSubmissionBindingModel).</p>
  
  <p>The view page for the user's input renders correctly and the Select Submission Category select box has the correct options for each submission category.</p>
  
  <p>Below is the HTML on the create submission form</p>
  
  <pre><code>&lt;div class="form-group"&gt;
      &lt;label asp-for="SelectedSubmissionCategory"&gt;&lt;/label&gt;
      &lt;select asp-for="SelectedSubmissionCategory" asp-items="@Model.SubmissionCategoryItems"&gt;
           &lt;option value="" selected&gt;--select--&lt;/option&gt;
      &lt;/select&gt;
      &lt;span asp-validation-for="SelectedSubmissionCategory"&gt;&lt;/span&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p><strong>My problem occurs if the user does not enter a required value on the form but then clicks on the submit button for the form.</strong></p>
  
  <p>My controller class has the CreateSubmission method below which gets called when the user clicks submit on the form</p>
  
  <pre><code>public IActionResult CreateSubmission(BaseSubmissionBindingModel baseSubmissionBindingModel) {
  
          if (! ModelState.IsValid) {
  
              return View("Index", baseSubmissionBindingModel);
          }
  
          Log.Information("Submission data provided is " + baseSubmissionBindingModel.ToString());
  
          return View("Success", baseSubmissionBindingModel);
  
      }
  </code></pre>
  
  <p>If the user submits the form without providing all the required data then the model's state is invalid.  The initial view is returned to the user along with the validation error messages.</p>
  
  <p>However the select box for the submission category no longer has any options for the submission categories retrieved from the database.  So the user can no longer select a submission category.</p>
  
  <p><strong>How can I ensure the submission category select box still has its option elements if the user fails to initially provide all the required data but still submits the form?</strong></p>
  
  <p>Thank you for the help.</p>
  
  <p>Bruce</p>