我已經實現MVC開發的類似的事情:
查看:
// Creating html Table from data present in model
<table class="content-wrapper">
<tr>
<th>
@Html.DisplayName("Name")
</th>
<th>
@Html.DisplayName("ID")
</th>
<th>
@Html.DisplayName("Designation")
</th>
<th>
</th>
</tr>
@foreach (var item in Model.lstEmployees)
{
<tr>
<td>
@Html.DisplayFor(modelItem => item.name)
</td>
<td>
@Html.DisplayFor(modelItem => item.id)
</td>
<td>
@Html.DisplayFor(modelItem => item.designation)
</td>
<td>
@Html.ActionLink("Edit", "Edit", new { id = item.id })
@Html.ActionLink("Delete", "Delete", new { id = item.id })
</td>
</tr>
}
控制器:
public ActionResult Delete(Data model)
{
//Code for delete
return View("Index", data);
}
[HttpGet]
public ActionResult Edit(Int32 Id)
{
//code for binding the existing records
return View(_data);
}
[HttpPost]
public ActionResult Edit(string sampleDropdown, Data model)
{
//code for saving the updated data
return RedirectToAction("Index", "Home");
}
組合可以制定出這樣的場景。 – Imran