title: Html.DropDownList selected value not working using ViewBag
body: <p>Well, after a couple hours reading stuff over here, trying unsuccessfully all the solutions, also found <a href="http://publicityson.blogspot.com/2010/07/aspnet-mvc-htmldropdownlist-not-showing.html" rel="noreferrer">this article</a> that i thought it would save my life... nothing. </p>
  
  <p>Long story short.</p>
  
  <p>Here is my View (all combinations)</p>
  
  <pre><code>@Html.DropDownList("yearDropDown",(IEnumerable&lt;SelectListItem&gt;)ViewBag.yearDropDown)
  @Html.DropDownList("yearDropDownxxx",(IEnumerable&lt;SelectListItem&gt;)ViewBag.yearDropDown)
  @Html.DropDownList("yearDropDown",(&lt;SelectList&gt;)ViewBag.yearDropDown)
  @Html.DropDownList("yearDropDown")
  </code></pre>
  
  <p>Here is my Controller</p>
  
  <pre><code>public ActionResult(int year)
  {
  var years = new int[] { 2007, 2008, 2009, 2010, 2011, 2012 }
                  .Select(x =&gt; new SelectListItem { 
                      Text = x.ToString(), 
                      Value = x.ToString(), 
                      Selected=x==year }).Distinct().ToList();
  
              years.Insert(0, new SelectListItem { Value = null, Text = "ALL YEARS" });
              ViewBag.yearDropDown = new SelectList(years, "Value", "Text", years.Where(x =&gt; x.Selected).FirstOrDefault());
  return View();
  }
  </code></pre>
  
  <p>Here is my rendered HTML. Selected nowhere to be found.</p>
  
  <pre><code>&lt;select id="yearDropDown" name="yearDropDown"&gt;&lt;option value=""&gt;ALL YEARS&lt;/option&gt;
  &lt;option value="2007"&gt;2007&lt;/option&gt;
  &lt;option value="2008"&gt;2008&lt;/option&gt;
  &lt;option value="2009"&gt;2009&lt;/option&gt;
  &lt;option value="2010"&gt;2010&lt;/option&gt;
  &lt;option value="2011"&gt;2011&lt;/option&gt;
  &lt;option value="2012"&gt;2012&lt;/option&gt;
  &lt;/select&gt;
  </code></pre>
  
  <p>Needless to mention, but i will, i checked in my Watch and SelectList actually has SelectedValue property populated with the selected year passed to the controller. But when i renders at the view, it goes to the first option.</p>
  
  <p>Please, I need the solution for <code>DropDownList</code>, NOT for <code>DropDownListFor</code>. I am highlighting this because i saw other people here asking for the same help and bunch of people gave them instructions, and almost order them, to use DropDownListFor. There is a reason why i NEED to use DropDownList.</p>
  
  <p>SOLUTION:
  Look at my own answer.
  However, here are the simple changes i made.</p>
  
  <p>Controller:</p>
  
  <pre><code>ViewBag.yearDropDown = years;
  </code></pre>
  
  <p>View:</p>
  
  <pre><code>@Html.DropDownList("yearDropDown")
  </code></pre>