title: mvc - dropdownlist not populating correctly within Edit view
body: <p>I'm building my first MVC application, having followed the 'NerdDinner' tutorial through. In creating a dropdownlist from a SelectList in the same way, however, I'm running into an issue.</p>
  
  <p>For some reason, when I bring up the 'Edit' view, the dropdownlist isn't showing the correct selection, even though the data is set otherwise in the database and the 'Details' view shows the correct value. Every one is just coming up with the first value in the list.</p>
  
  <p>I've been through the NerdDinner code piece by piece and can't for the life of me see any difference, yet that application will correctly show the dropdown with the current value when editing, and mine doesn't.</p>
  
  <p>Anyone have a suggestion for where to go from here? I can post code snippets if someone asks for something specific.</p>
  
  <p><strong>Update:</strong></p>
  
  <p>Within a fieldset:</p>
  
  <pre><code>        &lt;p&gt;
              &lt;label for="Parking"&gt;Parking Arrangement:&lt;/label&gt;
              &lt;%= Html.DropDownList("Parking", Model.Parking)%&gt;
              &lt;%= Html.ValidationMessage("Parking", "*") %&gt;
          &lt;/p&gt;
  </code></pre>
  
  <p>The Edit action:</p>
  
  <pre><code>    //
      // GET: /Buyer/Edit/2
      public ActionResult Edit(int id)
      {
          Buyer_Profile buyer_profile = buyerRepository.GetBuyerProfileByID(id);
  
          if (buyer_profile == null)
              return View("NotFound");
          else if (!buyer_profile.IsOwnedBy(User.Identity.Name, id))
              return RedirectToAction("Index", "Home");
          else
              return View(new BuyerFormViewModel(buyer_profile));
      }
  </code></pre>
  
  <p>In the same way they construct it for the NerdDinner example, I created a '...FormViewModel':</p>
  
  <pre><code>public class BuyerFormViewModel
  {
      // Properties
      public Buyer_Profile Buyer_Profile { get; private set; }
      public SelectList Parking { get; private set; }
  
      // Constructor
      public BuyerFormViewModel(Buyer_Profile buyer_profile)
      {
          Buyer_Profile = buyer_profile;
          Parking = new SelectList(BuyerProfileOptions.Parking, Buyer_Profile.Parking);
      }
  }
  </code></pre>
  
  <p>And the generated HTML when clicking on 'edit' when a value is already shown in the details view and stored in the d/b:</p>
  
  <pre><code>&lt;p&gt;
    &lt;label for="Parking"&gt;Parking Arrangement:&lt;/label&gt;
    &lt;select id="Parking" name="Parking"&gt;&lt;option&gt;No Preference&lt;/option&gt;
    &lt;option&gt;On Street&lt;/option&gt;
    &lt;option&gt;Assigned Street&lt;/option&gt;
    &lt;option&gt;Open Garage&lt;/option&gt;
    &lt;option&gt;Covered Garage&lt;/option&gt;
    &lt;/select&gt;                
  &lt;/p&gt;
  </code></pre>
  
  <p>The text fields in the same form have their values populated correctly. It's just all the dropdowns which don't!</p>
  
  <p>Many thanks for your attention.</p>