title: ASP.NET MVC View Model not binding on HTTP Post with DropDownList
body: <p>I am having an issue that when I post to a controller I lose binding and everything in my view  model is NULL. Here is the code I am using:</p>
  
  <p><strong>View:</strong></p>
  
  <pre><code>@model ArticleCategoryVm
  
  @using (@Html.BeginForm())
  {
      @Html.HiddenFor(model =&gt; model.LanguageIdDisplayed)
  
      &lt;label&gt;Name: &lt;span class="label label-important"&gt;Required&lt;/span&gt;&lt;/label&gt;
      @Html.HmlValidationFor(model =&gt; model.CategoryName)
      @Html.TextBoxFor(model =&gt; model.CategoryName, new { maxlength = "255", placeholder = "Category Name", @class = "input-xlarge-fluid" })                  
      &lt;span class="help-block"&gt;The is the name of the category and how it appears on the site.&lt;/span&gt;
  
      &lt;label&gt;Language: &lt;span class="label label-important"&gt;Required&lt;/span&gt;&lt;/label&gt;
      @Html.HmlValidationFor(model =&gt; model.LanguageId)
      @Html.DropDownList("LanguageId", new SelectList(@Model.Languages, "Value", "Text"), "Select language", new { @class="input-xlarge-fluid" })
      &lt;span class="help-block"&gt;This will be the language that the category is set too.&lt;/span&gt;
  
      &lt;label&gt;Parent:&lt;/label&gt;
      @Html.HmlValidationFor(model =&gt; model.CategoryParentId)
      @Html.DropDownList("CategoryParentId", new SelectList(@Model.CategoryParents, "Value", "Text"), new { @class = "input-xlarge-fluid" })
      &lt;span class="help-block"&gt;Allows you to group the category under another existing category.&lt;/span&gt;
  
      &lt;label&gt;Moderator Email: &lt;span class="label label-important"&gt;Required&lt;/span&gt;&lt;/label&gt;
      @Html.HmlValidationFor(model =&gt; model.ModeratorEmail)
      @Html.TextBoxFor(model =&gt; model.ModeratorEmail, new { maxlength = "255", placeholder = "Email Address", @class = "input-xlarge-fluid" })
      &lt;span class="help-block"&gt;This is the moderator email for articles in this category.&lt;/span&gt;
  
      &lt;button type="submit" class="btn btn-duadua btn-small"&gt;&lt;i class="icon-ok-3"&gt;&lt;/i&gt; Add New Category&lt;/button&gt;                      
  }
  </code></pre>
  
  <p><strong>ViewModel:</strong></p>
  
  <pre><code>public class ArticleCategoryVm : BaseLayoutVm
  {
      public int LanguageIdDisplayed;
      public List&lt;ArticleCategoryItemVm&gt; ArticleCategoryItemVms { get; set; }
  
      // Add Category Fields
      [Required]
      public string CategoryName;
  
      [EmailAttribute]
      [Required]
      public string ModeratorEmail;
  
      [Required]
      public int LanguageId;
  
      public int CategoryParentId;
  
      public List&lt;SelectListItem&gt; Languages { get; set; }
      public List&lt;SelectListItem&gt; CategoryParents { get; set; }
  }
  </code></pre>
  
  <p><strong>Controller:</strong></p>
  
  <pre><code>[HttpPost]
  public ActionResult Categories(ArticleCategoryVm vm)
  {
     // Code here
     if (ModelState.IsValid)
     {
     }
  
     ReDrawDropDowns(vm);
     return View(vm)
  }
  </code></pre>
  
  <p>Why is everything in my viewmodel NULL? I can see in using Chromes tools that in the post the values are being posted for the strings and ints... As a work around I have just done the following to get the code working:</p>
  
  <p><strong>Workaround Controller:</strong></p>
  
  <pre><code>[HttpPost]
  public ActionResult Categories(int LanguageIdDisplayed, string CategoryName, string ModeratorEmail, int LanguageId, int CategoryParentId)
  {
      var vm = new ArticleCategoryVm()
      {
          CategoryName = CategoryName,
          LanguageIdDisplayed = LanguageIdDisplayed,
          ModeratorEmail = ModeratorEmail,
          LanguageId = LanguageId,
          CategoryParentId = CategoryParentId
      };
  
      if (ModelState.IsValid)
      {
      }
  
      ReDrawDropDowns(vm);
      return View(vm)
  }
  </code></pre>
  
  <p>Thanks</p>