title: MVC3 Dropdown List returning NULL in Model Object
body: <p>I am trying to get a dropdown list to send back it's selection on HTTP POST along with the other related data.  I can see the value inside a Form Collection, but I VS2010 tells me that the object is NULL when I look at the other posted entities.  </p>
  
  <p>This model has a many to one relationship:</p>
  
  <pre><code>[Key]
  public int ProgramTypeId { get; set; }
  
  public string ProgramType { get; set; }
  
  public List&lt;SurveyProgramModels&gt; SurveyProgramModel { get; set; }
  </code></pre>
  
  <p>This model uses the ProgramTypeId as a foreign key</p>
  
  <pre><code>public class SurveyProgramModels
      {
          [Key]
          public Guid ProgramId { get; set; }
  
          public virtual SurveyProgramTypeModels SurveyProgramTypeModels { get; set; }
  
          public int ProgramYear { get; set; }
  
          public int ProgramStatus { get; set; }
  
      }
  </code></pre>
  
  <p>Controller GET/POST</p>
  
  <pre><code>  //
          // GET: /SurveyProgram/Create
  
          public ActionResult Create()
          {
  
              SelectList typelist = new SelectList(db.SurveyProgramTypeModels.ToList(), "ProgramTypeId", "ProgramType", db.SurveyProgramTypeModels);
              ViewData["SurveyProgramTypeModels"] = typelist;
  
              return View();
          } 
  
          //
          // POST: /SurveyProgram/Create
  
          [HttpPost]
          public ActionResult Create(SurveyProgramModels surveyprogram, FormCollection collection)
          {
  
  
              SelectList typelist = new SelectList(db.SurveyProgramTypeModels.ToList(), "ProgramTypeId", "ProgramType", db.SurveyProgramTypeModels);
              ViewData["SurveyProgramTypeModels"] = typelist;
  
            //  int SelectedCollection = Int32.Parse(collection["ProgramTypeId"]);
  
              if (ModelState.IsValid)
              {
                surveyprogram.ProgramId = Guid.NewGuid();
  
                  db.SurveyPrograms.Add(surveyprogram);
                  db.SaveChanges();
                  return RedirectToAction("Index");  
              }
  
              return View(surveyprogram);
          }
  </code></pre>
  
  <p>Select list in the view:</p>
  
  <pre><code>&lt;div class="editor-field"&gt;
              @Html.DropDownList("ProgramTypeTypeModels", (IEnumerable&lt;SelectListItem&gt;)ViewData["SurveyProgramTypeModels"])
              @Html.ValidationMessageFor(model =&gt; model.SurveyProgramTypeModels)
          &lt;/div&gt;
  </code></pre>
  
  <p>The Select list is correct when rendered in the view, and I can see the selected value as a part of the form collection.  I'm not sure why the selected value isn't being saved along with the other data for SurveyProgramModels.  </p>
  
  <p>Edit:  I should also mention the data submits correctly when I remove the relationship between the two classes.</p>