title: Set default value of Html.DropDownListFor from List ASP.Net
body: <p>I have this model</p>
  
  <pre><code>public class foo
  {
     public foo()
     {
        this.barList = new List&lt;bar&gt;();
     }
     public string name { get; set; }
     public List&lt;bar&gt; barList { get; set; }
  }
  
  public class bar
  {
     public string sample1 { get; set; }
     public string sample2 { get; set; }
     public string sample3 { get; set; }
  }
  </code></pre>
  
  <p>I am trying to display these values in view but I am not able to display the value that is supposedly be displayed in <code>Html.DropDownListFor</code></p>
  
  <p>Here is how I render it on my view:</p>
  
  <pre><code>@foreach (var item in Model.barList)
  {
    &lt;div&gt;
       @item.sample1
    &lt;/div&gt;
    &lt;div&gt;
      @{
          var status = new SelectList(
          new List&lt;SelectListItem&gt;
          {
                              new SelectListItem {Text = "text1", Value = "value1"},
                              new SelectListItem {Text = "text2", Value = "value2"},
                              new SelectListItem {Text = "text3", Value = "value3"}
          }, "Value", "Text");
      }
       @Html.DropDownListFor(m =&gt; item.sample2, status, "-- Select -- ", new { @class = "w100 form-control" })
    &lt;/div&gt;
    &lt;div&gt;
       @item.sample3
    &lt;/div&gt;
  }
  </code></pre>
  
  <p>What I am trying to do is set the selected value for the <code>DropDownList</code> to the value in the variable <code>sample2</code> on which value it matches on the select list. But somehow there is no value that is being selected when I try this code.</p>