I have list of model and send it to view. i want delete a few row of model list. how to delete from list in view?
List<Booking> models = new List<Booking>();
foreach (string id in items)
{
models.Add(
new Booking()
{ ...}
}
return View(models);
and into view:
<main id="BigPanel" class="flexcol border_radius" role="main">
@using (Html.BeginForm("FinalReserve", "Booking", FormMethod.Post, new { @class = "cart-rooms flexcol" }))
{
for (int i = 0; i < Model.Count; i++)
{
<div class="cart-room setborder border_radius flexrow">
@Html.HiddenFor(m => Model[i].Price)
@Html.HiddenFor(m => Model[i].RRId)
@Html.HiddenFor(m => Model[i].CheckOutDate)
<span>@Model[i].FromDate</span>
<span>@Model[i].CheckInDayName</span>
<span>@Model[i].DiscountPercent</span>
<span>@Model[i].Price</span>
<button onclick="removelist(@Model[i].RRId)"> Delete</button>
</div>
}
<hr style="width:100%;" />
<div class="cart-room flexrow">
<div class="sum flex1 flexcol">
<div class="flexrow">
<span class="flex1">@Model.Sum(m => m.Price)</span>
</div>
<div class="paybtn-group">
<button class="btns" onclick="history.go(-1); return false;"> back </button>
<button class="mbtn_green btn_cart" type="submit">
submit
</button>
</div>
</div>
</div>
}
</main>
when user click delete button, the row must deleted from list. and other row's submited. thanks.