title: Setting default value of a Html.DropDownList()
body: <p>When it posts back I get the following error:</p>
  
  <blockquote>
    <p>The ViewData item that has the key 'ClosingDateDay' is of type 'System.Int32' but must be of type 'IEnumerable'. Any ideas?</p>
  </blockquote>
  
  <p>Here's my Controller:</p>
  
  <pre><code>CompetitionEditViewModel viewModel = new CompetitionEditViewModel
  {
      ClosingDate = competition.CloseDate,
      Description = competition.Description,
      DescriptionHeading = competition.DescriptionHeading,
      ImageAssetId = competition.ImageAssetId,
      IsActive = competition.IsActive,
      MainHeading = competition.MainHeading,
      TermsAndConditions = competition.TermsAndConditions,
      UrlSlug = competition.UrlSlug
  };
  
  viewModel.ClosingDateMonthOptions = new List&lt;SelectListItem&gt;();
  for (int i = 1; i &lt;= 12; i++)
  {
      string monthName = new DateTime(2000, i, 1).ToString("MMMM");
      ((List&lt;SelectListItem&gt;)viewModel.ClosingDateMonthOptions).Add(new SelectListItem { Text = monthName, Value = i.ToString() });
  }
  
  viewModel.ClosingDateDayOptions = new List&lt;SelectListItem&gt;();
  for (int i = 1; i &lt;= 31; i++)
  {
      ((List&lt;SelectListItem&gt;)viewModel.ClosingDateDayOptions).Add(new SelectListItem { Text = i.ToString().PadLeft(2, '0'), Value = i.ToString() });
  }
  
  viewModel.ClosingDateYearOptions = new List&lt;SelectListItem&gt;();
  for (int i = DateTime.Now.Year; i &lt;= DateTime.Now.Year + 3; i++)
  {
      ((List&lt;SelectListItem&gt;)viewModel.ClosingDateYearOptions).Add(new SelectListItem { Text = i.ToString(), Value = i.ToString() });
  }
  </code></pre>
  
  <p>And heres my view:</p>
  
  <pre><code>@Html.Uber().LabelFor(x =&gt; x.ClosingDateDay, new { @class = "access" })
  @Html.DropDownListFor(x =&gt; x.ClosingDateDay, Model.ClosingDateDayOptions, Model.ClosingDateDay)
  
  @Html.Uber().LabelFor(x =&gt; x.ClosingDateMonth, new { @class = "access" })
  @Html.DropDownListFor(x =&gt; x.ClosingDateMonth, Model.ClosingDateMonthOptions, Model.ClosingDateMonth)
  
  @Html.Uber().LabelFor(x =&gt; x.ClosingDateYear, new { @class = "access" })
  @Html.DropDownListFor(x =&gt; x.ClosingDateYear, Model.ClosingDateYearOptions, Model.ClosingDateYear)
  </code></pre>