title: How to get the CheckBox selected value in insert into database controller in MVC3?
body: <p>Hi all i have to get the selected value from checkbox into my post method into insert into the database controller. How can i do this?</p>
  
  <pre><code>My Model Code
  -----------------
  using System;
  using System.Collections.Generic;
  using System.Linq;
  using System.Web;
  using System.Data;
  using System.Data.SqlClient;
  using System.Data.Entity;
  using System.Collections;
  
  namespace Gridview_BugTracker.Models
  {
      public class BugTracker_DataHelper
      {
  
          public static List&lt;BugTracker_DataHelper&gt; GetList{get;set;}
  
             public int ProjectId { get; set; }
             public string projectName { get; set; }           
             public string Description { get; set; }
             public  string status { get; set; }
             public int EmployeId { get; set; }
             public string EmployeName { get; set; }
             public bool selectChkbox { get; set; }         
        }      
  
     }
  
      My Control code
      ------------------------------
  
       using System;
      using System.Collections.Generic;
      using System.Linq;
      using System.Web;
      using System.Web.Mvc;
      using System.Data;
      using Gridview_BugTracker.Models;
      using System.Data.SqlClient;
      using System.Data.Entity;
  
      namespace Gridview_BugTracker.Controllers
      {
          public class ProjectsController : Controller
          {
              //
              // GET: /Projects/
              /// &lt;summary&gt;
              ///
              /// &lt;/summary&gt;
              /// &lt;returns&gt;&lt;/returns&gt;
              public ActionResult Index()
              {
                  var bugedlist = GetList();
                  return View(bugedlist);
              }
  
              /// &lt;summary&gt;
              /// The Bind data in Gridview
              /// &lt;/summary&gt;
              /// &lt;returns&gt;&lt;/returns&gt;
              public List&lt;BugTracker_DataHelper&gt; GetList()
              {
                  var modelList = new List&lt;BugTracker_DataHelper&gt;();
                  using (SqlConnection conn = new SqlConnection(@"Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=BugTracker;Data Source=SSDEV6\SQLEXPRESS"))
                  {
                      conn.Open();
                      SqlCommand dCmd = new SqlCommand("Select * from Projects", conn);
                      SqlDataAdapter da = new SqlDataAdapter(dCmd);
                      DataSet ds = new DataSet();
                      da.Fill(ds);
                      conn.Close();
                      for (int i = 0; i &lt;= ds.Tables[0].Rows.Count - 1; i++)
                      {
                          var model = new BugTracker_DataHelper();
                          model.ProjectId = Convert.ToInt16(ds.Tables[0].Rows[i]["ProjectId"]);
                          model.projectName = ds.Tables[0].Rows[i]["projectName"].ToString();
                          model.Description = ds.Tables[0].Rows[i]["Description"].ToString();
                          model.status = ds.Tables[0].Rows[i]["Status"].ToString();
                          modelList.Add(model);
                      }
                  }
                  return modelList;
              }
  
              /// &lt;summary&gt;
              /// Assign The Project Display
              /// &lt;/summary&gt;
              /// &lt;returns&gt;&lt;/returns&gt;
              [AcceptVerbs(HttpVerbs.Get)]
              public ViewResult AssignProject()
              {
  
                  ViewBag.ProjectId = new SelectList(Assinedwork(), "ProjectId", "projectName");           
                  var employees = CheckBoxBindEmpName();
                  return View(employees);
              }
  
              /// &lt;summary&gt;
              /// Assignwork
              /// &lt;/summary&gt;
              /// &lt;returns&gt;&lt;/returns&gt;        
              public List&lt;BugTracker_DataHelper&gt; Assinedwork()
              {
                  var modelList = new List&lt;BugTracker_DataHelper&gt;();
  
                  using (SqlConnection assignedconn = new SqlConnection(@"Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=BugTracker;Data Source=SSDEV6\SQLEXPRESS"))
                  {
                      {
                          assignedconn.Open();
                          SqlCommand Passnedcmd = new SqlCommand("select ProjectId,projectName from Projects", assignedconn);
                          SqlDataAdapter da = new SqlDataAdapter(Passnedcmd);
                          DataSet ds = new DataSet();
                          da.Fill(ds);
  
                          for (int i = 0; i &lt;= ds.Tables[0].Rows.Count - 1; i++)
                          {
                              var model = new BugTracker_DataHelper();
                              model.ProjectId = Convert.ToInt16(ds.Tables[0].Rows[i]["ProjectId"]);
                              model.projectName = ds.Tables[0].Rows[i]["projectName"].ToString();
                              modelList.Add(model);
                          }
                      }
                      return modelList;
                  }
              }
  
              public List&lt;BugTracker_DataHelper&gt; CheckBoxBindEmpName()
              {
                  var modecheckbox = new List&lt;BugTracker_DataHelper&gt;();
  
                  using (SqlConnection assignedconn = new SqlConnection(@"Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=BugTracker;Data Source=SSDEV6\SQLEXPRESS"))
                  {
                      {
                          assignedconn.Open();
                          SqlCommand Chkcmd = new SqlCommand("select EmployeId,EmployeeName from EmployeeDetails", assignedconn);
                          SqlDataAdapter Chkda = new SqlDataAdapter(Chkcmd);
                          DataSet chkds = new DataSet();
                          Chkda.Fill(chkds);
  
                          for (int i = 0; i &lt;= chkds.Tables[0].Rows.Count - 1; i++)
                          {
                              var modelchk = new BugTracker_DataHelper();
                              modelchk.EmployeId = Convert.ToInt16(chkds.Tables[0].Rows[i]["EmployeId"]);
                              modelchk.EmployeName = chkds.Tables[0].Rows[i]["EmployeeName"].ToString();
                              modecheckbox.Add(modelchk);
                          }
  
                      }
                  }
                  return modecheckbox;
           }
          }
  
      }
      My Assinedcode View code
      ------------------------
  
       &lt;%@ Page Language="C#" Inherits="System.Web.Mvc.ViewPage&lt;IEnumerable&lt;Gridview_BugTracker.Models.BugTracker_DataHelper&gt;&gt;" %&gt;
  
      &lt;!DOCTYPE html&gt;
  
      &lt;html&gt;
      &lt;head runat="server"&gt;
          &lt;title&gt;AssignProject&lt;/title&gt;
      &lt;/head&gt;
      &lt;body&gt;
          &lt;div&gt;
           &lt;% using (Html.BeginForm()) 
           { %&gt;      
          &lt;%:Html.ValidationSummary(true)%&gt;
           &lt;fieldset&gt;
              &lt;legend&gt;Projects&lt;/legend&gt;
                          &lt;%: Html.DropDownList("ProjectId")%&gt;
                          &lt;%: Html.ValidationMessage("ProjectId")%&gt;                   
                          &lt;fieldset style="color:Blue;"&gt;                 
  
                          &lt;% foreach (var item in Model) { %&gt;  
                        &lt;div&gt;
                        &lt;%:Html.CheckBox(item.EmployeName) %&gt;
                        &lt;%:Html.LabelForModel(item.EmployeName) %&gt;
                        &lt;/div&gt;                 
                      &lt;%} %&gt;
                            &lt;p&gt;
                            &lt;input type="submit" value="Assign" /&gt;
                           &lt;/p&gt;      
  
              &lt;/fieldset&gt;
          &lt;%} %&gt;
  
          &lt;/div&gt;
      &lt;/body&gt;
      &lt;/html&gt;
  </code></pre>
  
  <p>now i want to get the selected value EmployeeName  Parameter in my postmedthod in insert into database. Can anyone help me with how i should do this?</p>