我試圖在表單提交時將整個模型數據返回給索引文章。它只返回通過URL參數傳遞的ID。爲什麼?索引帖子不能將整個模型返回給控制器?
@using Volunteer.BootstrapSupport
@model IEnumerable<Volunteer.Models.Activity>
@using (Html.BeginForm())
{
<h2>Member Volunteering List </h2>
<div>
<button type="submit" class="btn btn-primary" >New Activity</button>
</div>
<table id="volunteerlist" class="table table-striped table-bordered table-hover .table-condensed">
<thead>
<tr>
<th>
@Html.DisplayNameFor(model => model.Committee.Name)
</th>
<th>
@Html.DisplayNameFor(model => model.Committee.Type)
</th>
<th>
@Html.DisplayNameFor(model => model.Role)
</th>
<th>
@Html.DisplayNameFor(model => model.EndDate)
</th>
<th>
@Html.DisplayNameFor(model => model.Source)
</th>
<th></th>
</tr>
你確定你在這裏正確地複製了你的視圖嗎?你的模型是一個IEnumerable,但沒有跡象表明你在某處循環。您在這裏展示的視圖是無效的,即'model.'不會給出'Activity'的任何屬性,因爲它(模型)是Activity的集合。 – 2013-03-22 13:53:02
我沒有看到輸入元素可以在這裏保存你的值,你只是用DisplayNameFor生成標籤。 – tpeczek 2013-03-22 14:12:04