title: MVC DropDownList populate from one DB table and send to another DB table
body: <p>I would like to have a dropdownlist which pulls data from a qualification table and then on HttpPost it stores the value selected in the dropdownlist to a &quot;qualification&quot; column on the employee table. I'm very new to MVC and I don't really know the syntax very well. I also don't know how to use jquery, vb etc. so sorry if there is a post out there that covers this and I've not seen it because I don't know what I'm looking at.</p>
  <p>This is currently my best attempt at doing this:</p>
  <p><strong>Controller:</strong></p>
  <pre><code>private Database1Entities db = new Database1Entities();
  ...
  ...
  ...
      // GET: /Home/CreateEmp
              public ActionResult CreateEmp()
              {
                  ViewBag.QualList = new SelectList(db.Qualifications, &quot;Id&quot;, &quot;qual&quot;);
                  return View();
              }
              // POST: /Home/CreateEmployee
              [HttpPost, ActionName(&quot;CreateEmployee&quot;)]
              public ActionResult CreateEmpResult(Employee emp)
              {
                  if (ModelState.IsValid)
                  {
                      db.Employees.Add(emp);
                      db.SaveChanges();
                      return RedirectToAction(&quot;Index&quot;);
                  }
                  ViewBag.QualList = new SelectList(db.Qualifications, &quot;Id&quot;, &quot;qual&quot;, emp.qualification);
                  return View(emp);
              }
  </code></pre>
  <p><strong>Create Employee View:</strong></p>
  <pre><code>@model MvcDropDownList.Models.Employee
      @using (Html.BeginForm(&quot;CreateEmployee&quot;, &quot;Home&quot;, FormMethod.Post))
      {
          @Html.AntiForgeryToken()
          @Html.ValidationSummary(true)
          &lt;table&gt;
          &lt;!-- other fields removed for sake of simplicity --&gt;
          &lt;tr&gt;
              &lt;td&gt;
                  @Html.Label(&quot;Select Your Qualification:&quot;)
              &lt;/td&gt;
  
              &lt;td&gt;
                  @Html.DropDownList(&quot;QualList&quot;, &quot;--Select--&quot;)
              &lt;/td&gt;
          &lt;/tr&gt;
      &lt;/table&gt;
      }
  </code></pre>
  <p><strong>Table Structure:</strong></p>
  <blockquote>
  <p>Qualifications Table: Id, qual</p>
  <p>Employee Table: Id, firstName, surName, gender, qualification</p>
  </blockquote>
  <p>My code successfully gets the data from the &quot;Qualification&quot; table but doesn't post it to the &quot;qualification&quot; column in the &quot;employee&quot; table.</p>
  <p>Any suggestions will be greatly appreciated, Thank you!</p>