I have a partial view that sits in my main view like this:
<div id="complaintlist">
@Html.Action("ShowCaseComplaints", "Cases", new { caseid = Model.CasesID })
</div>
This is the partial view:
@model IEnumerable<cummins_db.ViewModels.CaseComplaintsViewModel>
<table width="100%">
<tr>
<th></th>
<th></th>
<th>Complaint Code</th>
<th>Complaint Description</th>
<th>Delete</th>
</tr>
@foreach (var item in Model)
{
<tr>
<td>
@Html.HiddenFor(modelItem => item.CasesID )
</td>
<td>
@Html.HiddenFor(modelItem => item.CaseComplaintID )
</td>
<td>
@Html.DisplayFor(modelItem => item.ComplaintCode )
</td>
<td>
@Html.DisplayFor(modelItem => item.ComplaintType)
</td>
<td>
@Ajax.ActionLink("Delete", "RemoveCodeFromCase", "Cases", new { caseid = item.CasesID, id = item.CaseComplaintID }, null)
</td>
</tr>
}
</table>
This partial view has an action that allows the user to remove a record from the model in the partial view. Here is the action called RemoveCodeFromCase:
public ActionResult RemoveCodeFromCase(int caseid, int id)
{
if (ModelState.IsValid)
{
CaseComplaint c = db.CaseComplaints.Find(id);
db.CaseComplaints.Remove(c);
db.SaveChanges();
var data = (from C in db.CaseComplaints
where C.CasesID == caseid
select new CaseComplaintsViewModel()
{
CasesID = C.CasesID,
CaseComplaintID = C.ComplaintCodeID,
ComplaintCode = C.ComplaintCode.ComplaintCodeName,
ComplaintType = C.ComplaintCode.ComplaintType
}).ToList();
return PartialView("_CaseComplaintCodes", data);
}
return PartialView("_CaseComplaintCodes");
}
I am trying to understand how to refresh my partial view after this action runs.
Thx