title: MVC dropdownlist : Setting the value and text based upon table in database
body: <p>I have a table in database</p>
  
  <p><img src="https://i.stack.imgur.com/TYtVo.png" alt="enter image description here"></p>
  
  <p>I've been able to show the list of TypeName in my dropdownlist in my View</p>
  
  <p>Currently i'm doing this is my controller</p>
  
  <pre><code> [HttpGet]
          public ActionResult CreateModule()
          {
              var moduleTypes = _db.ModuleTypes.Select(moduleType =&gt; moduleType.TypeName).ToList();
              var model = new CreateModule
                  {
                      TypeNames = moduleTypes.Select(m =&gt; new SelectListItem
                          {
                              Value = m,
                              Text = m,
                          })
                  };
              return View(model);
  
          }
  </code></pre>
  
  <p>and in view</p>
  
  <pre><code> &lt;div class ="input-block-level"&gt;@Html.DropDownListFor(model =&gt; model.SelectedModuleTypeName, Model.TypeNames)&lt;/div&gt;
  </code></pre>
  
  <p>That results to something like this
  <img src="https://i.stack.imgur.com/tvbzT.png" alt="enter image description here"></p>
  
  <p>based upon my code, I'll get the <code>TypeName</code> from the view in my controller's post method.
  How I can I change my code in order to access <code>Id</code> of the <code>TypeName</code> in controller?</p>