in a MVC C# View I show the records of specifics employees, for that I use MVCScaffolding and the model below
public class Developer
{
public int code { get; set; }
public string areaDev { get; set; }
public string nameDev { get; set; }
public string expDev { get; set; }
public string langDev { get; set; }
}
the view uses razor and for every record there is a checkbox input
@model IEnumerable<WebApplication1.Models.Developer>
@using(Html.BeginForm("ShowRecords","Home"))
{
<table class="table">
<tr>
<th>@Html.DisplayNameFor(model => model.code)</th>
<th>@Html.DisplayNameFor(model => model.areaDev)</th>
<th>@Html.DisplayNameFor(model => model.nameDev)</th>
<th>@Html.DisplayNameFor(model => model.expDev)</th>
<th>@Html.DisplayNameFor(model => model.langDev)</th>
<th>select</th>
</tr>
@foreach (var item in Model) {
<tr>
<td>@Html.DisplayFor(modelItem => item.code)</td>
<td>@Html.DisplayFor(modelItem => item.areaDev)</td>
<td>@Html.DisplayFor(modelItem => item.nameDev)</td>
<td>@Html.DisplayFor(modelItem => item.expDev)</td>
<td>@Html.DisplayFor(modelItem => item.langDev)</td>
<td><input type="checkbox" name="code" value="@item.code" /></td>
</tr>
}
</table>
<input type="submit" value="SEND" />
}
and what I want is to retrieve the information of code(integer code) when the user click the checkbox of one/many specific records displayed in the view,
for that in my controller I receive a int[] as shown below
public ActionResult ShowRecords(int[] datos)
{
{
foreach(var item in datos)
{ ... some code goes here ... }
return View();
}
But I don't receive anything from the view, always receive NULL
could you please help me and tell how to retrieve the code info of the due checked row in my controller?
Aucun commentaire:
Enregistrer un commentaire