title: ASP.NET MVC - drop down list selection - partial views and model binding
body: <p>I'm fairly new to ASP.NET MVC and am trying to work out the best way to do this. It's probably simple but I just want to do things correctly so I thought I'd ask.</p>
  
  <p>Lets say I have a model that is this:</p>
  
  <p>Task - Id, Description, AssignedStaffMember </p>
  
  <p>StaffMember - Id, FirstName, LastName</p>
  
  <p>and in my view I want to create a new task. I make a strongly typed Razor view, and can use EditorFor to create textboxes for Description but what about AssignedStaffMember?</p>
  
  <p>I want a drop down list of all current staff and have the option of selecting one, then this gets submitted to an action method which is 
  <code>NewTask(string description, StaffMember assignedStaffMember)</code>
  either that or I could have an int for staffId instead of the StaffMember object and look it up in the action method.</p>
  
  <p>What is the best way to do this? I need to go to the database to get the list off staff, so here's what I thought:</p>
  
  <ol>
  <li><p>Make a partial view for the listing of staff drop down, which will be used a few times and use <code>@Html.Action("ListStaff", "Staff")</code> to call it. The action method then has </p>
  
  <pre><code>public ActionResult ListStaff()
  {
      IEnumerable&lt;StaffMember&gt; model = _serviceLayer.GetAllStaff();
      return PartialView(model);
  }
  </code></pre>
  
  <p>However I'm not sure on how this will work with model binding, my understanding is that it  has to have the correct name for the form to submit it, I'd need to pass the name to the partial view to put on the  element I guess?</p></li>
  <li><p>Instead of having it call a controller to get the staff, make a ViewModel that contains my Task and a IEnumerable possibleStaff collection. possibly send this information to a partial view. </p></li>
  <li><p>a Html Helper ? </p></li>
  <li><p>EditorFor could somehow be used? </p></li>
  </ol>
  
  <p>which one (or is there more) would be best? and how would I do the model binding?</p>