user3368990
user3368990

Reputation: 17

ID not passing to Controller

My drop down doesn't send EmplID to Controller, why ? All other drop down does but not this one, why ? i tried a lot

This view contains DropDown View:

 @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>


 }

This controller shoud accept value but emplID is null Controller:

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

Upvotes: 0

Views: 48

Answers (1)

Ahmed ilyas
Ahmed ilyas

Reputation: 5822

the parameter is different naming than what you have assigned to your drop down list. they must match

Upvotes: 2

Related Questions