title: How to select the default value from a dropdownlist when using asp.net mvc?
body: <p>This might seem a pretty simple question; </p>
  
  <p>I'm using the Pubs database with the Authors table. I have used Linq to SQL as my data access and I've created an edit view with ASP.net MVC. The last property of an author model is 'contract' which is a true/false value. What I am attempting to do is to create a DropDownList with the values 'yes' or 'no' and bind to that list when the pages loads with the value from the authors model. </p>
  
  <p>Here is what I have for the DropDownList markup:</p>
  
  <pre><code>Html.DropDownList("dropDownList", new[]
  {                        
     new SelectListItem { Text = "Yes", Value = "true" }, 
     new SelectListItem { Text = "No", Value = "false" } 
  })
  </code></pre>
  
  <p>The view model comes back as this:</p>
  
  <pre><code> model.contract
  </code></pre>
  
  <p>which is a boolean value of 'true' or 'false'.</p>
  
  <p>What would be the easiest way set the correct value in the dropdown list using the model's value?</p>
  
  <p><strong>Answer</strong></p>
  
  <p>Instead of using just :</p>
  
  <pre><code>model.contract
  </code></pre>
  
  <p>I went ahead and used:</p>
  
  <pre><code>Model.contract 
  </code></pre>
  
  <p>Which accessed the page level model which is where I needed to be. After that everything else came together.</p>