Example:
Model:
public class Exemplo
{
public int Id { get; set; }
public string Nome { get; set; }
}
Controller and View:
public ActionResult Index()
{
IList<Exemplo> exemplos = new List<Exemplo>();
exemplos.Add(new Exemplo {Id = 1, Nome = "Nome 1"});
exemplos.Add(new Exemplo { Id = 2, Nome = "Nome 2" });
return View(exemplos);
}
@{ ViewBag.Title = "Index"; }
@using (Html.BeginForm("Resgatar", "Exemplo", FormMethod.Post))
{
<table class="table">
<tr>
<td>
@Html.Display("Selecionar")
</td>
<th>
@Html.DisplayNameFor(model => model.Nome)
</th>
<th></th>
</tr>
@foreach (var item in Model)
{
<tr>
<td>
<input type="checkbox" name="Ids" value="@item.Id" />
</td>
<td>
@Html.DisplayFor(modelItem => item.Nome)
</td>
<td>
@Html.ActionLink("Edit", "Edit", new { id = item.Id }) |
@Html.ActionLink("Details", "Details", new { id = item.Id }) |
@Html.ActionLink("Delete", "Delete", new { id = item.Id })
</td>
</tr>
}
<tr>
<td colspan="4">
<button type="submit" class="btn btn-primary">Alterar</button>
</td>
</tr>
</table>
}
Controller with ActionResult of Ids selected:
[HttpPost]
public ActionResult Resgatar(IEnumerable<int> Ids)
{
return View();
}
In this way you will receive an Id list of all those selected. Please rebase the search on your database and change the required data.