title: Pass model and extra parameter from view to an action in MVC
body: <p>I am trying to pass a <code>userid</code> to my action in controller .my action is like this as you can see here: </p>
  
  <pre><code>[HttpPost]
          [Authorize(Roles = "Admin,Expert")]
          public ActionResult AddExpert(AssistanceJuror assistanceJuror,int UserId)
          {
              User user = objUserRepository.FindBy(i =&gt; i.Id == assistanceJuror.UserId).First();
              user.Enable = "فعال";
              assistanceJuror.Date = DateTime.Now;
              objUserRepository.Edit(user);
              objUserRepository.Save();
              objAssistanceJurorRepository.Add(assistanceJuror);
              TempData["Message"] = "کارشناس به معاونت اختصاص داده شد";
              objAssistanceJurorRepository.Save();
              return RedirectToAction("IndexExpert", "Assistance");
          }
  </code></pre>
  
  <p>So this action expect 2 parameters ,one of that is my model and another one is <code>userId</code> .so i need to get both values from the view my view is like this :</p>
  
  <pre><code>@using ViewModelDomain
  @using Repository;
  @model DomainClass.AssistanceJuror
  
  @{
      ViewBag.Title = "AddExpert";
  }
  
  @using (Html.BeginForm())
  {
      @Html.ValidationSummary(true)
      &lt;div class="wrapper-left"&gt;
          &lt;div class="wrapper-top-addCompany"&gt;
              انتساب کارشناس به معاونت
              &lt;div style="float: left; padding-left: 20px;"&gt;
                  &lt;div class="divider"&gt;&lt;/div&gt;
                  &lt;div class="buttonPossion"&gt;
                      @Html.ActionLink("بازگشت", "Index", "Assistance", new { companyid = ViewBag.firstIdeaId }, new { @class = "buttonBlueLink" })
                  &lt;/div&gt;
                  &lt;div class="divider"&gt;&lt;/div&gt;
              &lt;/div&gt;
          &lt;/div&gt;
          &lt;div class="wrapper-Member" style="padding-bottom: 30px; margin-bottom: 5px; width: 100%; min-height: 550px;"&gt;
              &lt;h2&gt;اضافه کردن کارشناس جدید
              &lt;/h2&gt;
              &lt;br /&gt;
              &lt;br /&gt;
              &lt;br /&gt;
              &lt;div class="editor-label"&gt;
                  انتخاب معاونت
              &lt;/div&gt;
              &lt;div class="editor-field"&gt;
                  @Html.DropDownListFor(model =&gt; model.AssistanceId, (SelectList)ViewBag.listAssistance)
              &lt;/div&gt;
  
              &lt;div class="editor-label"&gt;
                  انتخاب کارشناس
              &lt;/div&gt;
              @*                &lt;div class="editor-field"&gt;
                      @Html.DropDownListFor(model =&gt; model.userId, (SelectList)ViewBag.listDisableExpert)
                  &lt;/div&gt;*@
              @{
      if (User.IsInRole("Expert") || User.IsInRole("Admin"))
      {
                  &lt;div class="wrapper-Member" style="border-top: 1px solid #d3d3d3; margin-top: 30px; width: 99.5%; border-left: 1px solid #d3d3d3; margin-right: 1px"&gt;
                      &lt;div class="tab-list-company" style="margin-right: -1px; width: 180px"&gt;
                          &lt;h2 style="font: normal 13px BHoma; margin-right: 10px; margin-top: 2px;"&gt;اختصاص کارشناس به معاونت
                          &lt;/h2&gt;
                      &lt;/div&gt;
                      &lt;div class="list-company" style="border: none; width: 98%"&gt;
                          &lt;table&gt;
                              &lt;thead&gt;
                                  &lt;tr&gt;
                                      &lt;th&gt;نام و نام خانوادگی&lt;/th&gt;
                                      &lt;th&gt;سطح تحصیلات&lt;/th&gt;
                                      &lt;th&gt;رشته تحصیلی&lt;/th&gt;
                                      &lt;th&gt;شماره همراه&lt;/th&gt;
                                      &lt;th&gt;تلفن&lt;/th&gt;
                                      &lt;th&gt;ایمیل&lt;/th&gt;
                                      @if (User.IsInRole("Expert") || User.IsInRole("Admin"))
                                      {
                                          &lt;th style="width: 20px;"&gt;اضافه&lt;/th&gt;
                                      }
                                  &lt;/tr&gt;
                              &lt;/thead&gt;
                              @{
                                      userRepository objUserRepository = new userRepository();
                                      //var listJuror = objUserRepository.FindBy(i =&gt; i.Permission == "Juror").ToList();
                                  List&lt;DomainClass.User&gt; listDisableAssistance = objUserRepository.ReturnUserByEnablePermission("غیرفعال", "Assistance");
                              }
  
                              @foreach (var temp in listDisableAssistance)
                              {
                                  &lt;tr&gt;
                                      &lt;td&gt;
                                          @{
                                  string fullName = temp.Name + " " + temp.Family;
                                          }
                                          @Html.DisplayFor(modelItem =&gt; fullName)
                                      &lt;/td&gt;
                                      &lt;td&gt;
                                          @Html.DisplayFor(modelItem =&gt; temp.EducationLevel)
                                      &lt;/td&gt;
                                      &lt;td&gt;
                                          @Html.DisplayFor(modelItem =&gt; temp.Field)
                                      &lt;/td&gt;
                                      &lt;td&gt;
                                          @Html.DisplayFor(modelItem =&gt; temp.Mobile)
                                      &lt;/td&gt;
                                      &lt;td&gt;
                                          @Html.DisplayFor(modelItem =&gt; temp.Tell)
                                      &lt;/td&gt;
                                      &lt;td&gt;
                                          @Html.DisplayFor(modelItem =&gt; temp.Email)
                                      &lt;/td&gt;
                                      &lt;td&gt;
  
  
                                              @using (Html.BeginForm("AddExpert", "Assistance", routeValues: new { userid = temp.Id }))
                                         {
                                          &lt;input type="submit" value=""  class="Add" title="اضافه کردن" /&gt;
                                         }    
                                      &lt;/td&gt;
                                  &lt;/tr&gt;
                              }
  
                          &lt;/table&gt;
                      &lt;/div&gt;
                  &lt;/div&gt;
      }
              }
          &lt;/div&gt;
      &lt;/div&gt;
  
  }
  @section Scripts {
      @Scripts.Render("~/bundles/jqueryval")
  }
  </code></pre>
  
  <p>In this part </p>
  
  <pre><code>   &lt;td&gt;
  
  
                                                  @using (Html.BeginForm("AddExpert", "Assistance", routeValues: new { userid = temp.Id }))
                                             {
                                              &lt;input type="submit" value=""  class="Add" title="اضافه کردن" /&gt;
                                             }    
                                          &lt;/td&gt;
  </code></pre>
  
  <p>I am trying to pass my <code>userId</code> to my action but it doesn't work and i get an error that says the userid is null .</p>
  
  <p>Best regards</p>