title: ASP.NET Struggling with generating a dropdown list in view and posting back to controller
body: <p>I've googled this and tried so many different variations. I think the issue I'm having is there are so many ways to do this, and I'm not seeing the wood for the trees.</p>
  
  <p>I have a list of equipment in a database. Each row is assigned to a company. There could be 10 pieces of equipment for company "Contoso Ltd", 23 pieces of equipment for "Geldof Industries" etc.</p>
  
  <p>I have a scaffolded view using entity framework to display all the equipment for the entire database. This works fine.</p>
  
  <p>What I want to do is have a dropdown list on the view, which populates with a list of distinct companies in the table and selecting a company then filters the results in the view.</p>
  
  <p>At the moment my controller has this:</p>
  
  <pre><code>    var serverList = from s in db.tbl_equipment
                       where (s.Company == "Contoso Ltd") &amp;&amp; (s.Calc_Contract_Status == true)
                       where (s.Equip_type == "PC") || (s.Equip_type == "Laptop") || (s.Equip_type == "Mac") || (s.Equip_type == "Tablet") || (s.Equip_type.Contains("Server"))
                       select s;
  
      return View(serverList.ToList());
  </code></pre>
  
  <p>As I understand it, I would populate a dropdown list based on a LINQ query, and use a viewbag to send that to the view then use a Dropdownlistfor html helper to create the dropdown. I'd assume I'd then need to capture the post request in someway back in the controller.</p>
  
  <p>Every single site I have found for generating a dropdownlist in Razor and ASP.NET Entity Framework is different. Any help would be much appreciated!</p>