title: ASP.Net Html.DropDownList Selected Element not Selected
body: <p>I have a site that was using ASP.Net MVC Beta 5, and I have just upgraded it to ASP.Net MVC 1.0. I am having trouble with the selected item in a drop down list.</p>
  
  <p>The follow person has a similar question (<a href="https://stackoverflow.com/questions/589935/html-dropdownlist-in-asp-net-mvc-rc-refresh-not-pre-selecting-item">Html.DropDownList in ASP.NET MVC RC (refresh) not pre-selecting item</a>) but I there is no answer (other than it might be a bug)</p>
  
  <p>My Controller method looks as follows:</p>
  
  <pre><code>[AcceptVerbs(HttpVerbs.Get)]
  public ActionResult View(Guid id)
  {
      IntegrationLogic logic = new IntegrationLogic(new IntegrationLinq());
      CompanyLogic companyLogic = new CompanyLogic(new CompanyLinq());
      IntegrationContainer container = new IntegrationContainer();
  
      container.Sources = logic.GetImportSource(id);
      container.Companies = companyLogic.GetCompanies(); // Returns a IList&lt;company&gt;
      container.SourceActions = logic.GetAllSourceActions(); // Returns an IList&lt;SourceAction&gt;
      container.SinkActions = logic.GetAllSinkActions();
      container.SuccessActions = logic.GetAllSuccessActions();
      container.FailureActions = logic.GetAllFailureActions();
      container.Actions = logic.GetAllActions();
      container.Watchers = logic.GetAllWatcherActions();
      container.ChainActions = logic.GetAllChainActions();
  
      return View("View", container);
   }
  </code></pre>
  
  <p>The view is a strongly typed against the Model as follows</p>
  
  <pre><code>public partial class View : ViewPage&lt;IntegrationContainer&gt; {}
  </code></pre>
  
  <p>The problem area in the view template is :</p>
  
  <pre><code>  &lt;label for="Companies"&gt;Company: &lt;/label&gt;&lt;%=Html.DropDownList("Companies",
                                                  new SelectList(ViewData.Model.Companies, "id", "name", item.CompanyID))%&gt;
  </code></pre>
  
  <p>I am creating a Dropdown List, the selected item never actually gets selected - and that is the problem.  "item.CompanyID" is a Guid, "id" is a Guid and "name" is a string on the company object supplied in the IList that is held in the ViewData.Model.Companies instance.</p>
  
  <p>Is this actually a bug ?- I find it hard to understand why this is still present in ASP.Net MVC... I would be totally happy if it is something I have done.</p>
  
  <p>Regardless, what would be the suggested work around? </p>
  
  <p>Thanks</p>