MVC表单提交不同的值

时间:2015-11-25 14:43:28

标签: c# model-view-controller

假设我有以下表格

    <table class="table table-bordered table-condensed table-striped">
    <tr>
        <th>Company</th>
        <th>Contact Person</th>
        <th>Contact Number</th>
        <th>Registration Number</th>
        <th>Email</th>
        <th>Action</th>
    </tr>
    @Html.DisplayFor(model => model.Clients)
</table>

显示模板

@model InspectManagement.DAL.Client
<tr>
    <td>
        @Html.HiddenFor(model => model.ID)
        @Html.DisplayFor(model => model.Name)
    </td>
    <td>
        @Html.DisplayFor(model => model.Surname)
    </td>
    <td>
        @Html.DisplayFor(model => model.CellNumber)
    </td>
    <td>
        @Html.DisplayFor(model => model.IdNumber)
    </td>
    <td>
        @Html.DisplayFor(model => model.Email)
    </td>
    <td>
        <a href='@Url.Action("Edit","Clients")/Model.ID' class="btn btn-primary">Edit</a>
    </td>
</tr>

我的当前代码有效但它会使我的网址路径为xxx / Clients / Edit / 1

我知道我应该在表单中使用提交按钮,但是如何为提交按钮提供一个特定值来提交(在表单内)我想要执行以下操作

<% using(Html.BeginForm("Edit", "Clients")) %>
<% { %>
    <!-- table with multiple submit buttons with different values to submit to Edit -->
<% } %>

0 个答案:

没有答案