Update I was pointing to the incorrect view in the controller.
Not sure what i'm missing but my item being passed is what the view want's for a model. When Clicking Delete to remove an entry.
The model item passed into the dictionary is of type PAL.Intranet.Models.FeeSchedule_CCGNInsured, but this dictionary requires a model item of type System.Collections.Geeric.IEnumerable1[PAL.Intranet.Models.FeeSchedule_CCGNInsured]
Insured
@model IEnumerable<PAL.Intranet.Models.FeeSchedule_CCGNInsured>
@{
ViewBag.Title = "CCGN Insured Fee Schedule";
Layout = "~/Views/Shared/_Layout.cshtml";
}
<link href="~/Content/CSS/MetroButtonWidth.css" rel="stylesheet" />
<h2>CCGN Insured Fee Schedule</h2>
<hr class="bg-dark" />
@if (User.IsInRole("Intranet Admins"))
{
<p>
<button class="button small-button info buttonWidth100" onclick="location.href='@Url.Action("CCGNInsuredCreate", "FeeSchedule")'">Create New</button>
<br />
</p>
}
<table class="table hovered bordered striped border">
<tr>
<th class="fg-white bg-dark">
CPT
</th>
<th class="fg-white bg-dark">
Description
</th>
<th class="fg-white bg-dark">
Insured Office Fee
</th>
<th class="fg-white bg-dark">
10% Coin
</th>
<th class="fg-white bg-dark">
20% Coin
</th>
<th class="fg-white bg-dark">
30% Coin
</th>
<th class="fg-white bg-dark">
Insured Non Office Fee
</th>
<th class="fg-white bg-dark">
10% Coin
</th>
<th class="fg-white bg-dark">
20% Coin
</th>
<th class="fg-white bg-dark">
30% Coin
</th>
</tr>
@foreach (var item in Model) {
<tr>
<td class="text-small">
@Html.DisplayFor(modelItem => item.CPT)
</td>
<td class="text-small">
@Html.DisplayFor(modelItem => item.Description)
</td>
<td class="text-small">
@Html.DisplayFor(modelItem => item.InsuredOfficeFee)
</td>
<td class="text-small">
@Html.DisplayFor(modelItem => item.IOF10)
</td>
<td class="text-small">
@Html.DisplayFor(modelItem => item.IOF20)
</td>
<td class="text-small">
@Html.DisplayFor(modelItem => item.IOF30)
</td>
<td class="text-small">
@Html.DisplayFor(modelItem => item.InsuredNonOfficeFee)
</td>
<td class="text-small">
@Html.DisplayFor(modelItem => item.INOF10)
</td>
<td class="text-small">
@Html.DisplayFor(modelItem => item.INOF20)
</td>
<td class="text-small">
@Html.DisplayFor(modelItem => item.INOF30)
</td>
@if (User.IsInRole("Intranet Admins"))
{
<td>
<button class="button small-button info buttonWidth75" onclick="location.href='@Url.Action("CCGNInsuredEdit", "FeeSchedule", new { id = item.ID })'">Edit</button>
<button class="button small-button danger buttonWidth75" onclick="location.href='@Url.Action("CCGNInsuredDelete", "FeeSchedule", new { id = item.ID })'">Delete</button>
</td>
}
</tr>
}
</table>
<button class="button small-button danger buttonWidth75" onclick="location.href='@Url.Action("CCGNInsuredDelete", "FeeSchedule", new { id = item.ID })'">Delete</button>
Controller
public ActionResult CCGNInsuredDelete(Guid? id)
{
if (id == null)
{
return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
}
FeeSchedule_CCGNInsured FeeSchedule_CCGNInsured = db.FeeSchedule_CCGNInsured.Find(id);
if (FeeSchedule_CCGNInsured == null)
{
return HttpNotFound();
}
return View("/Views/FeeSchedule/CCGN/InsuredIndex.cshtml", FeeSchedule_CCGNInsured);
}
Delete View
@model PAL.Intranet.Models.FeeSchedule_CCGNInsured
You are passing a single object of FeeSchedule_CCGNInsured
to your view InsuredIndex.cshtml
which must contain the following definition:
@model IEnumerable<PAL.Intranet.Models.FeeSchedule_CCGNInsured>
(or a collection derived from IEnumerable
)
Either change your FeeSchedule_CCGNInsured
view to use a single instance of FeeSchedule_CCGNInsured
or update your return to forward it to the delete view you mention:
return View("/Views/FeeSchedule/CCGN/delete.cshtml", FeeSchedule_CCGNInsured);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.