1

大家好,我必须从下拉列表中获取选定的值到我在控制器中的 post 方法中,而不是解决分配按钮 ..我该怎么做

MY modelcode
------------

 namespace Gridview_BugTracker.Models
{
    public class BugTracker_DataHelper
    {

        public static List<BugTracker_DataHelper> 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; }  


      }      

   }

我的控制器

[AcceptVerbs(HttpVerbs.Post)]
        public ActionResult DropCheckInsert(int ProjectId, string EmployeName, FormCollection collection, BugTracker_DataHelper bughelperdata)
        {    

            var modeldropdownlist = new BugTracker_DataHelper();
           SqlConnection Assignworkconn = new SqlConnection(@"Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=BugTracker;Data Source=SSDEV6\SQLEXPRESS");
            {
                Assignworkconn.Open();
                SqlCommand insertcommande = new SqlCommand("sp_Insert", Assignworkconn);
                insertcommande.CommandType = CommandType.StoredProcedure;
                insertcommande.Parameters.Add("@EmployeId", SqlDbType.VarChar).Value = EmployeName;
                insertcommande.Parameters.Add("@projectId", SqlDbType.VarChar).Value = ProjectId;

                insertcommande.ExecuteNonQuery();
            }
            return View(modeldropdownlist);

}
}

}


My View code
------------------

<%@ Page Language="C#" Inherits="System.Web.Mvc.ViewPage<IEnumerable<Gridview_BugTracker.Models.BugTracker_DataHelper>>" %>

<!DOCTYPE html>

<html>
<head runat="server">
    <title>AssignProject</title>
</head>
<body>
    <div>
     <% using (Html.BeginForm()) 
     { %>      
    <%:Html.ValidationSummary(true)%>       
     <fieldset>
        <legend>Projects</legend>
                    <%: Html.DropDownList("ProjectId", (SelectList)ViewBag.ProjectId, "--Select Project--")%>
                    <%: Html.ValidationMessage("ProjectId")%>                


                    <fieldset style="color:Blue;">                 

                    <% foreach (var item in Model) { %>  
                  <div>
                  <%:Html.CheckBox(item.EmployeName) %>
                  <%:Html.LabelForModel(item.EmployeName) %>
                  </div>                 
                 <%} %>



             <p>
             <input type="submit" value="Assign" />
             </p> 

        </fieldset>
       <%-- @Html.DropDownListFor(m => m.Contact.StateId, new SelectList(Model.States, "Id", "Name", @Model.Contact.StateId))--%>  


    <%} %>


    </div>
</body>

现在我想在我的 postmedthod 中获取选定的值 projectId 参数,而不是工作分配按钮。谁能帮我解决这个问题?

4

0 回答 0