title: DropDownList SelectedValue not binding properly
body: <p>I have a DropDownList populated with a SelectList generated from (an anonymous type) that has two properties "CountryId" (int) and "Description" (string). I want the selected country in the list to be the defaultCountry.</p>
  
  <pre><code>Countries = new SelectList(countries, "CountryId", "Description", defaultCountry.CountryId);
  </code></pre>
  
  <p>where "countries" is an IQueryable of anonymous types from a Linq query. Countries is a public property on a view model:</p>
  
  <pre><code>public class CountryBaseViewModel
  {
       public SelectList Countries { get; set; }
       public Contact Contact { get;set; }
       ....
  }
  </code></pre>
  
  <p>The HTML looks like this:</p>
  
  <pre><code>&lt;p&gt;
  &lt;label for="CountryId"&gt;Home Country:&lt;/label&gt;
  &lt;%= Html.DropDownList("CountryId", Model.Countries)%&gt;
  &lt;/p&gt;
  </code></pre>
  
  <p>This is fine and when I load the page, the correct country is selected.</p>
  
  <p>But when I submit the change to the Edit method on the controller, the binding seems to fail.</p>
  
  <p>For example, when I use the following HTML</p>
  
  <pre><code>&lt;p&gt;
  &lt;label for="Contact.Job"&gt;Job/Post:&lt;/label&gt;
  &lt;%= Html.TextBox("Contact.Job", Model.Contact.Job) %&gt;
  &lt;/p&gt;
  </code></pre>
  
  <p>And I call the method </p>
  
  <pre><code>public ActionResult Create(Contact contact)
  </code></pre>
  
  <p>on the controller, then the contact.Job value is correctly filled in from the TextBox but the CountryId is not. </p>
  
  <p>I presume MVC uses the "Contact.Job" (TextBox 1st) parameter to set this. But the first parameter of the DropDownList is "CountryId" not "Contact.CountryId" because if it is, then the selected value is not shown in the list when I load it.</p>
  
  <p>It looks like the first parameter of TextBox is for data binding and the first parameter of DropDownList is to Find the selected item.</p>
  
  <p>How do I use this style of data binding to get to the selected value I want in the DropDownList and then tie that to Model.Contact.Country?</p>