title: Populating Drop down list with ViewBag in Asp.net
body: <p>I have made a View named ManageSalesman, it has two sub Views named AddOrEdit and it contains a form. Here I want to populate the Vendor companies list in the drop down from the Vendor table in the database, for that I get them in view bag in the following code. </p>
  
  <pre><code>ViewBag.Vendor = new SelectList(db.Vendors, "Id", "name");
  </code></pre>
  
  <p>and make drop down list in AddOrEdit by the following line of code.</p>
  
  <pre><code> @Html.DropDownListFor(model =&gt; model.CompanyId, new SelectList(ViewBag.Vendor, "Id", "name"), "Select Vendor Company", new { @class = "form-control" })
  </code></pre>
  
  <p>but when I run it, it will show me: Argument null exception "Additional information: Value cannot be null." Kindly tell me what I am doing wrong.</p>