title: How to pass value from submit button to mvc dynamically?
body: <p>I started working with MVC from few days and got a question out of learning lot of ways to communicate between Controllers and Views in MVC</p>
  
  <p>I have page that shows list of employees in tabular form.</p>
  
  <p>Model is of type <code>IEnumerable</code> of <code>Employee Model</code></p>
  
  <p>It has three buttons they are <code>Edit</code>, <code>Create</code>, <code>Delete</code>, <code>Details</code>.</p>
  
  <p><strong>Requirement:</strong> <br>
  I used buttons so that all should be of HTTP Post request type because I do not want users to directly access them using URL requests.</p>
  
  <p>Here is my view code:</p>
  
  <pre><code>@using (Html.BeginForm())
  {
      &lt;p&gt;
          &lt;input type="submit" name="CreateView" value="Create New(Post)" formaction="CreateView" formmethod="post" /&gt;
      &lt;/p&gt;
      &lt;table class="table"&gt;
          &lt;tr&gt;
              -------Headings of table-------
          &lt;/tr&gt;
          @foreach (var item in Model)
          {
          &lt;tr&gt;
              &lt;td&gt;@Html.DisplayFor(modelItem =&gt; item.EmployeeName)&lt;/td&gt;
              &lt;td&gt;@Html.DisplayFor(modelItem =&gt; item.EmployeeGender)&lt;/td&gt;
              &lt;td&gt;@Html.DisplayFor(modelItem =&gt; item.EmployeeCity)&lt;/td&gt;
              &lt;td&gt;@Html.DisplayFor(modelItem =&gt; item.DepartmentId)&lt;/td&gt;
              &lt;td&gt;@Html.DisplayFor(modelItem =&gt; item.EmployeeDateOfBirth)&lt;/td&gt;
              &lt;td&gt;
                  &lt;input type="submit" name="EditView" value="Edit(Post)" formaction="Edit" formmethod="post" /&gt; |
                  &lt;input type="submit" name="DetailsView" value="Details(Post)" formaction="Details" formmethod="post" /&gt; |
                  &lt;input type="submit" value="Delete(Post)" onclick="return confirm('Are you sure you want to delete record with EmployeeId = @item.EmployeeId')" /&gt;
              &lt;/td&gt;
          &lt;/tr&gt;
          }
      &lt;/table&gt;
  }
  </code></pre>
  
  <p>Here delete button works because I do not need the id of the employee.
  But for other actions like editing, deleting and details viewing I need to pass Employees Id to controller. But how do I pass the Id to the controller using submit button.</p>
  
  <p>In get requests types I used to pass like this:</p>
  
  <pre><code>@Html.ActionLink("Details", "Details", new { id = item.EmployeeId })
  </code></pre>
  
  <p>For single submit button I used to pass data like this</p>
  
  <pre><code>@using (Html.BeginForm("Details", "BusinessLayer", FormMethod.Post, new { id = item.EmployeeId }))
  </code></pre>
  
  <p>Can any one tell me the approach that I can fallow to achieve this?</p>