I'm working with Dynamic Checkbox, I trying to get CheckBox Value from another already Created table. But When I Do Code For DropDownList it can Be Working but same as it is not working for CheckBox
following is My Method
public IEnumerable<clsHobbyList> GetHobby() { List<clsHobbyList> lstHobby = new List <clsHobbyList>(); using (SqlConnection con = new SqlConnection(ConnectionString)) { SqlCommand cmd = new SqlCommand("spAddHoby", con); cmd.CommandType = CommandType.StoredProcedure; con.Open(); SqlDataReader rdr = cmd.ExecuteReader(); while (rdr.Read()) { clsHobbyList hby = new clsHobbyList(); hby.Id = Convert.ToInt32(rdr["Id"]); hby.HobbyName = rdr["HobbyName"].ToString(); lstHobby.Add(hby); } con.Close(); } return lstHobby; }Following Is My Controller
public ActionResult Create() { EmployeeDataAccessLayer objemployee = new EmployeeDataAccessLayer(); clsHobbyList hby = new clsHobbyList(); ViewBag.Hobby = new SelectList(objemployee.GetHobby(), "Id", "HobbyName"); return View(); }and this is my View Page, hear How Can I Get CheckBox ?? please suggest me some solution
<div class="form-group"> @Html.LabelFor(model => model.Hobby, htmlAttributes: new { @class = "control-label col-md-2" }) <div class="col-md-10"> @Html.DropDownList("Hobby", null, htmlAttributes: new { @class = "form-control" }) </div> @Html.ValidationMessageFor(model => model.Hobby, "", new { @class = "text-danger" }) </div>-----------Hear How Can I Get Checkbox--------------------------------------------