在控制器中从视图发送值到操作

时间:2013-06-09 17:46:36

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

我想将详细信息视图中的itemID发送到控制器中的操作方法 这是我的观点:

@model IEnumerable<GDMfrontEnd.Models.items>
@{
    ViewBag.Title = "Detail";
}

<h2>Detail</h2>
    @foreach (var item in Model)
    {
      @Html.DisplayFor(modelItem => item.item_description)
      @Html.DisplayFor(modelItem => item.item_title)
      @Html.DisplayFor(modelItem => item.item_createddate)
      @Html.DisplayFor(modelItem => item.deliverables.projects.project_name)
    }

    <a href="@Url.Action("Deliverable", "Bookmark", new { id =  }))">Add to favorites</a>
    </fieldset>

现在我想将item.item_id发送到我的可交付成果控制器中的动作“书签”。我怎么能这样做?

1 个答案:

答案 0 :(得分:3)

尝试:

@foreach (var item in Model)
{
  @Html.DisplayFor(modelItem => item.item_description)
  @Html.DisplayFor(modelItem => item.item_title)
  @Html.DisplayFor(modelItem => item.item_createddate)
  @Html.DisplayFor(modelItem => item.deliverables.projects.project_name)
  <a href="@Url.Action("Deliverable", "Bookmark", new { id = item.item_id }))">Add to favorites</a>
}