title: MVC 3 - Getting all selected values from a listbox on postback
body: <p>I have an MVC3 project that has a listbox (listboxfor) like this:</p>
  
  <pre><code>@Html.ListBoxFor(m =&gt; m.cat_fam_codes, new SelectList(BaanWrapper.GetAllCategoryFamilies(), "Code", "Description"), new { @size = "10" })
  </code></pre>
  
  <p>When testing, I am able to select multiple entries in the list and even added a event handler to popup the comma-limited list of the selected values when the they are selected.  However, when I post the form back to the controller, I only get the first selected value returned.  For example, if I select value 1,2,3,4 - my JQuery event handler will popup "1,2,3,4".  No problem - but on post back, the bound object referenced in the controller only shows a "1".</p>
  
  <pre><code>[HttpPost]
  public ActionResult Create(EventReport eventReport)
  {
      return View(eventReport);
  }
  </code></pre>
  
  <p>Any help would be greatly appreciated.</p>
  
  <p>EDIT:</p>
  
  <p>Here's the EventReport data model/class:</p>
  
  <pre><code>using System;
  using System.Collections.Generic;
  using System.ComponentModel;
  using System.ComponentModel.DataAnnotations;
  using System.Linq;
  
  namespace EWS.Models
  {
      [MetadataType(typeof(EventReportMetaData))]
      public partial class EventReport
      {
          private static readonly EWSDataContext db = new EWSDataContext();
  
          #region Nested type: MetaData
  
          private sealed class EventReportMetaData
          {
              [DisplayName("Alert Email Body")]
              [Required(ErrorMessage = "Required")]
              public string alert_body { get; set; }
  
              [DisplayName("Alert Email Subject")]
              [Required(ErrorMessage = "Required")]
              public string alert_subject { get; set; }
  
              [DisplayName("Categories")]
              public string cat_codes { get; set; }
  
              [DisplayName("Category Families")]
              public string cat_fam_codes { get; set; }
  
              [DisplayName("CCR Codes")]
              public string ccr_codes { get; set; }
  
              [Required(ErrorMessage = "Required")]
              public DateTime create_dtm { get; set; }
  
              [Required(ErrorMessage = "Required")]
              public int created_by { get; set; }
  
              [DisplayName("Email List")]
              [Required(ErrorMessage = "Required")]
              [IsInteger(ErrorMessage = "Invalid Email List")]
              [IsGreaterThanZero(ErrorMessage = "Required")]
              public int email_list_id { get; set; }
  
              [DisplayName("Begin Date")]
              public DateTime begin_dtm { get; set; }
  
              [DisplayName("End Date")]
              public DateTime end_dtm { get; set; }
  
              [DisplayName("Event Threshold")]
              [Required(ErrorMessage = "Required")]
              [IsInteger(ErrorMessage = "Invalid Threshold")]
              public int event_count { get; set; }
  
              [DisplayName("Disabled")]
              public bool is_disabled { get; set; }
  
              [DisplayName("Notify Over Threshold")]
              [Required(ErrorMessage = "Required")]
              public bool notify_over_events { get; set; }
  
              [DisplayName("Notify Under Threshold")]
              [Required(ErrorMessage = "Required")]
              public bool notify_under_events { get; set; }
  
              [Required(ErrorMessage = "Required")]
              public int report_id { get; set; }
  
              [DisplayName("Report Title")]
              [Required(ErrorMessage = "Required")]
              public string report_title { get; set; }
  
              [DisplayName("Reset By")]
              public int reset_by { get; set; }
  
              [DisplayName("Reset Date")]
              public DateTime reset_dtm { get; set; }
  
              [DisplayName("SKUs")]
              public string skus { get; set; }
  
              [DisplayName("Source System")]
              [Required(ErrorMessage = "Required")]
              public string source_system { get; set; }
  
              [DisplayName("Sub-Categories")]
              public string sub_cat_codes { get; set; }
  
              [DisplayName("# of Time Units")]
              [Required(ErrorMessage = "Required")]
              public int window_dt_part_count { get; set; }
  
              [DisplayName("Unit of Time")]
              [Required(ErrorMessage = "Required")]
              public string window_dt_part { get; set; }
          }
  
          #endregion
      }
  }
  </code></pre>
  
  <p>Thanks!</p>