I am developing a application where I need display details like ID, name and address of customers. And one should be able to edit or delete each customer details. For that I have added Edit and delete action links as buttons for reach row. In my controller I have added switch case to perform edit or delete actions.
My question is how to use action link as submit button. Or is there any better way to perform edit and delete records
View :
<table class="table">
<tr>
<th>
@Html.DisplayNameFor(model => model.id)
</th>
<th>
@Html.DisplayNameFor(model => model.name)
</th>
<th>
@Html.DisplayNameFor(model => model.address)
</th>
<th></th>
</tr>
@foreach (var item in Model)
{
<tr>
<td>
@Html.DisplayFor(modelItem => item.id)
</td>
<td>
@Html.DisplayFor(modelItem => item.name)
</td>
<td>
@Html.DisplayFor(modelItem => item.address)
</td>
<td>
@Html.ActionLink("Edit", "", new { id = item.id }) |
@Html.ActionLink("Delete", "", new { id = item.id })
</td>
</tr>
}
</table>
Controller :
[HttpPost]
public ActionResult MyTableView(int id, List<MyList> list)
{
switch (submitButton)
{
case "Delete":
break;
case "Edit" :
break;
}
return View ("MyTableView");
}