ID未传递给Controller

时间:2014-03-02 17:27:05

标签: asp.net asp.net-mvc asp.net-mvc-3 c#-3.0

我的下拉菜单没有向控制器发送EmplID,为什么?所有其他下降但不是这个,为什么?我尝试了很多次

此视图包含DropDown 查看:

 @using (Html.BeginForm("DeactivateAdmin", "Home", FormMethod.Post))
 {

     <fieldset>

       <label id="lblDD">Select Admin</label>
       <br />
       @Html.DropDownList("EmplID_Admin", "Select Name")
       <br />
       <br />
       <input type="submit" class="button_form" style="Width: 10.5% !important" value="Delete Admin" />

     </fieldset>


 }

此控制器应接受值,但emplID为null 控制器:

public ActionResult DeactivateAdmin(int? emplID) 
        {
            if (!String.IsNullOrEmpty(Session["Admin"] as string))
            {
                var DeactiveAdmin = DataContext.DeActivateAdmin_Sp(emplID);
            }
            else
            {
                return RedirectToAction("IsAuth_Page.cshtml", "Home");

            }
            return View();
        }

SP:

ALTER PROCEDURE [dbo].[DeActivateAdmin_Sp]

  @emplID int

AS
BEGIN
    -- SET NOCOUNT ON added to prevent extra result sets from
    -- interfering with SELECT statements.
    SET NOCOUNT ON;

   Update HrEmployee
   Set EmployeeType = 2 where EmplID= @emplID

END

1 个答案:

答案 0 :(得分:2)

参数的命名与分配给下拉列表的参数不同。他们必须匹配