我有一個窗體在頁面頂部有一個輸入部分,在下半部分它顯示了添加的對象列表。我需要能夠編輯和刪除這些對象,我不確定從哪裏開始或如何去做。在Asp.Net MVC中刪除和更新對象列表4
此代碼顯示對象列表。
@if (Model.ListOfRecipients != null)
{
for (int i = 0; i < Model.ListOfRecipients.Count; i++)
{
<div class='recipient-wrapper'>
<div class='decision_block'>
<table class='recipient'>
<tr>
<td class='recipient-title'>
@Html.HiddenFor(model=>model.ListOfRecipients[i].RecipientId)
<h3>
@Html.DisplayTextFor(model => model.ListOfRecipients[i].RecipientName)
@Html.HiddenFor(model => model.ListOfRecipients[i].RecipientName)
</h3>
<div class='delivery-type'>
Delivery Type: @Html.DisplayTextFor(model => model.ListOfRecipients[i].DeliveryType)
@Html.HiddenFor(model => model.ListOfRecipients[i].DeliveryType)
</div>
</td>
<td class='na express'>
@Html.CheckBoxFor(model => model.ListOfRecipients[i].ExpressIndicator)
@Html.HiddenFor(model => model.ListOfRecipients[i].ExpressIndicator)
</td>
<td class='quantity'>
<h3>
Qty @Html.DisplayTextFor(model => model.ListOfRecipients[i].Quantity)
@Html.HiddenFor(model => model.ListOfRecipients[i].Quantity)
</h3>
</td>
<td class='action'>
<input class='button edit_recipient' type='button' value='Edit' />
<input class='button delete_recipient' type='button' value='Delete' />
</td>
</tr>
</table>
<input class='button update_recipient' type='button' value='Update' />
<a class='cancel_update' href='#'>Cancel</a>
</div>
</div>
</div>
}
}
我已經添加在拍攝對象ID作爲參數控制器的刪除方法(我已經添加了對象ID作爲一個隱藏的領域不認爲它在我的代碼上面)我如何得到刪除按鈕發送正確的對象的ID? –
我想我需要這樣的刪除@ Html.ActionLink(「收件人」 ,MVC.Recipients.Delete(model => model.ListOfRecipients [i] .RecipientId) –
@RonaldMcDonald編輯我的答案,包含一個參數 –