Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8302233
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T17:14:09+00:00 2026-06-08T17:14:09+00:00

Hi guys i have to pass the checked value from checkbox and selected value

  • 0

Hi guys i have to pass the checked value from checkbox and selected value from DropDown,

my view looks like this

                        Project:DropDown
                   -----------------------------
           EmployeeNames
       --------------------------
      checkbox,AnilKumar
      checkBox,Ghouse

this is my aspx page

       <body>
<% using (Html.BeginForm())
   { %>

<%:Html.ValidationSummary(true)%>

<div></div><div style="margin:62px 0 0 207px;"><a style="color:Orange;">Projects : </a><%:Html.DropDownList("Projects")%></div>
<fieldset style="color:Orange;">

    <legend>Employees</legend>
      <% foreach (var item in Model)
         { %>  
              <div>
              <%:Html.CheckBox(item.EmployeeName)%>
              <%:Html.LabelForModel(item.EmployeeName)%>
              </div>
      <%} %>
      <%} %>
</fieldset>
<p>
<input type="button" value="AssignWork" /></p>

   </div>
 </body>

i have to get the all the checked employyee names with selected project ID from dropdown into my post method..how can i do this can any one help me here please

    this is my controller

         [AcceptVerbs(HttpVerbs.Get)]
public ActionResult AssignWork()
{
    ViewBag.Projects = new SelectList(GetProjects(), "ProjectId", "ProjectName");       
    var employee = GetEmployeeList();      
    return View(employee);
}

    public List<ResourceModel> GetEmployeeList()
{
        var EmployeeList = new List<ResourceModel>();
        using (SqlConnection conn = new SqlConnection("Data Source=LMIT-0039;Initial Catalog=BugTracker;Integrated Security=True"))
        {
            conn.Open();
            SqlCommand dCmd = new SqlCommand("select EmployeId,EmployeeName from EmployeeDetails", conn);
            SqlDataAdapter da = new SqlDataAdapter(dCmd);
            DataSet ds = new DataSet();
            da.Fill(ds);
            conn.Close();
            for (int i = 0; i <= ds.Tables[0].Rows.Count - 1; i++)
            {
                var model = new ResourceModel();
                model.EmployeeId = Convert.ToInt16(ds.Tables[0].Rows[i]["EmployeId"]);
                model.EmployeeName = ds.Tables[0].Rows[i]["EmployeeName"].ToString();
                EmployeeList.Add(model);
            }
            return EmployeeList;
        }
}

    public List<ResourceModel> GetProjects()
    {
         var roles = new List<ResourceModel>();
        SqlConnection conn = new SqlConnection("Data Source=LMIT-0039;Initial Catalog=BugTracker;Integrated Security=True");
        SqlCommand Cmd = new SqlCommand("Select ProjectId,projectName from  Projects", conn);
        conn.Open();
        SqlDataAdapter da = new SqlDataAdapter(Cmd);
        DataSet ds = new DataSet();
        da.Fill(ds);
        for (int i = 0; i <= ds.Tables[0].Rows.Count - 1; i++)
        {                                
            var model = new ResourceModel();
            model.ProjectId= Convert.ToInt16(ds.Tables[0].Rows[i]["ProjectId"]);
            model.ProjectName = ds.Tables[0].Rows[i]["projectName"].ToString();               
            roles.Add(model);
        }
          conn.Close();
          return roles ;

    }

    [AcceptVerbs(HttpVerbs.Post)]
    public ActionResult AssignWork(int projectid,string EmployeeName,FormCollection form,ResourceModel model)
    {

        using (SqlConnection conn = new SqlConnection("Data Source=LMIT-0039;Initial Catalog=BugTracker;Integrated Security=True"))
        {
            conn.Open();
            SqlCommand insertcommande = new SqlCommand("AssignWork", conn);
            insertcommande.CommandType = CommandType.StoredProcedure;
            insertcommande.Parameters.Add("@EmployeeName", SqlDbType.VarChar).Value = EmployeeName;
            insertcommande.Parameters.Add("@projectId", SqlDbType.VarChar).Value = projectid;
            //insertcommande.Parameters.Add("@Status", SqlDbType.VarChar).Value = model.status;
            insertcommande.ExecuteNonQuery();
        }
        return View();

    }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T17:14:11+00:00Added an answer on June 8, 2026 at 5:14 pm

    I changed the AssignWork post method with this

             [AcceptVerbs(HttpVerbs.Post)]
        public ActionResult AssignWork(FormCollection collection, string Projects, string EmployeId)
        {
            ViewBag.Projects = new SelectList(GetProjects(), "ProjectId", "ProjectName");
            if (!string.IsNullOrEmpty(collection["EmployeId"]))
            {
                //formCollection["check"] is a string content checked box value with format value1,value2,valu3....
                string[] temp = collection["EmployeId"].Split(',');
                for (int i = 0; i < temp.Length; i++)
                {
                    EmployeId = temp[i];
                    if (EmployeId != "false")
                    {
    
                        SqlConnection Assignworkconn = new SqlConnection("Data Source=LMIT-0039;Initial Catalog=BugTracker;Integrated Security=True");
                        {
                            Assignworkconn.Open();
                            SqlCommand insertcommande = new SqlCommand("AssignWork", Assignworkconn);
                            insertcommande.CommandType = CommandType.StoredProcedure;
                            insertcommande.Parameters.Add("@EmployeeName", SqlDbType.VarChar).Value = EmployeId;
                            insertcommande.Parameters.Add("@projectId", SqlDbType.Int).Value = Projects;
                            //put your insert code here with temp[i] is checked box value
                            insertcommande.ExecuteNonQuery();
                        }
                    }
                }
            }
            return RedirectToAction("AssignWork");
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Ok guys so I have a nested route like this: resources :apps do resources
Thus far you guys have been wildly helpful with me getting this little ditty
guys i have arrays in which i have to match this kind of text
Hy Guys, I have to pass in a method action a string parameter, because
This might be easy for you guys but i could't get it. I have
HI Guys, I have following problem. I'm trying to connect from my Iphone app
Hello guys i have a problem streaming PDF files with php, i'm using this
hello guys i have three server and i mange it from SSH so i
Hey guys I am not able to pass the variable profile through... This is
Possible Duplicate: Is Java pass by reference? Hi guys, I have a question about

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.