title: Generate CheckBoxList from a single column in MVC in .net
body: <p>I'm working on a HR project in MVC Entity Framework Database first.</p>
  
  <p>My view that I've tried is:</p>
  
  <pre><code>&lt;div class="form-group"&gt;
      @Html.LabelFor(model =&gt; model.emp_Disease, htmlAttributes: new { @class = "control-label col-md-2 " })
      &lt;div class="col-md-10" style="padding-top:6px;margin:0px;"&gt;
          @for (int i = 0; i &lt; Model.Disease.Count(); i++)
          {
            @Html.CheckBoxFor(model =&gt; model.Disease[i].emp_Disease)
            @Model.Disease[i].Name
            @Html.HiddenFor(model =&gt; model.Disease[i].Name)
            @Html.HiddenFor(model =&gt; model.Disease[i].id)
          }
          @Html.ValidationMessageFor(model =&gt; model.emp_Disease, "", new { @class = "text-danger" })
      &lt;/div&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>Controller action <code>HttpGet</code> is:</p>
  
  <pre><code>[HttpGet]
  public ActionResult Home(int id = 0)
  {
      tbl_employee emp = new tbl_employee();
      emp.Disease = CheckDisease();
      if (id != 0)
      {
          using (hrm_DB db = new hrm_DB())
          {
              emp = db.tbl_employee.Where(m =&gt; m.emp_Id == id).FirstOrDefault&lt;tbl_employee&gt;();
          }
      }
      return View(emp);
  }
  </code></pre>
  
  <p>And Model is:</p>
  
  <pre><code>public class Checkdisease
  {
      public int id { get; set; }
      public string Name { get; set; }
      public bool emp_Disease { get; set; }
  }
  </code></pre>
  
  <p>List is:</p>
  
  <pre><code>public List&lt;Checkdisease&gt; Disease { get; set; }
  </code></pre>
  
  <p>My problem is to how generate CheckBoxList from a single database column?</p>