I have been looking at other similar questions to this, but I can't seem to find a way to get this working. My view is being passed into a list of tAdminAlert objects that I list out in a table. I want a Delete button next to each row in the table that redirects to the Delete(tAdminAlert obj) action method in my controller and pass in the object corresponding to the row that they clicked.
My controller is called AdminAlerts and has this action method:
public ActionResult Delete(tAdminAlerts obj) {
// Want to call delete method on obj here
return View("Index");
}
My view looks like
@model List<tAdminAlerts>
@{
ViewData["Title"] = "Alerts";
}
@{
ViewBag.Title = "Alerts";
}
<div style="width:60%;display:table">
<table>
<thead>
<tr>
<th>Full Name</th>
<th>Email</th>
<th>Dept. Number</th>
<th>Dept. Code</th>
</tr>
</thead>
<tbody>
@foreach (var obj in Model) {
<tr>
<td width="35%">
@obj.nameFull
</td>
<td width="25%">
@obj.emailAddress
</td>
<td width="20%">
@obj.departmentNumber
</td>
<td width="20%">
@obj.departmentCode
</td>
<td>
* Want delete button to go here and return @obj
to Delete action method of controller *
</td>
</tr>
}
</tbody>
</table>
</div>
I would appreciate any help with this. Thanks!