title: How to use a ViewBag to create a dropdownlist?
body: <p>Controller:</p>
  
  <pre><code>public ActionResult Filter()
  {
      ViewBag.Accounts = BusinessLayer.AccountManager.Instance.getUserAccounts(HttpContext.User.Identity.Name);
      return View();
  }
  </code></pre>
  
  <p>View:</p>
  
  <pre><code>&lt;td&gt;Account: &lt;/td&gt;
  &lt;td&gt;@Html.DropDownListFor("accountid", new SelectList(ViewBag.Accounts, "AccountID", "AccountName"))&lt;/td&gt;
  </code></pre>
  
  <p><code>ViewBag.Accounts</code> contains <code>Account</code> objects which have <code>AccountID</code>, <code>AccountName</code> and other properties.
  I would like a <code>DropDownList</code> called <strong>accountid</strong> (so that on Form Post I can pass the selected AccountID) and the <code>DropDownList</code> to display the <code>AccountName</code> while having the <code>AccountID</code> as value.</p>
  
  <p>What am I doing wrong in the view code?</p>