Comment passer de la Liste de la vue d'un contrôleur MVC 4

J'ai manqué un petit quelque chose tout en passant une liste à partir de la vue du contrôleur. Il affiche la valeur null dans [HttpPost] méthode de contrôleur. Quelqu'un s'il vous plaît guide que comment puis-je obtenir la liste des données à partir de la vue du contrôleur. S'il vous plaît consulter mon code complet ci-dessous.

@model List<payorder_draft_printing.Models.registration>
@{
ViewBag.Title = "bulk_approval";
Layout = "~/Views/Shared/_Layout.cshtml";
}
<div class="container">
<div class="row" style="text-align: left">
<h2><u>Bulk Approval</u></h2>
<br />
<br />
@using (Html.BeginForm("bulk_approval", "Sms", FormMethod.Post, new { enctype = "multipart/form-data" }))
{
<div style="width: 700px;" align="center">
<table id="GetSerial" class="table">
<thead>
<tr class="ui-widget-header">
<th>Account Number</th>
<th>Mobile Number</th>
<th>Customer Name</th>
<th>Branch Code</th>
<th>Bulk Upload</th>
<th>Create Date</th>
<th>Created By</th>
<th>Active</th>
</tr>
</thead>
<tbody>
@if (Model != null)
{
foreach (var m in Model)
{
<tr style="height: 25px; border-bottom: 1px solid gray">
<td style="min-width: 120px">@m.account_number</td>
<td style="min-width: 120px; width: 450px;">@m.mobile_number</td>
<td style="min-width: 250px; width: 250px">@m.customer_name</td>
<td style="min-width: 100px; width: 100px">@m.BranchCode</td>
<td style="min-width: 100px; width: 100px">@m.BulkUpload</td>
<td style="min-width: 150px;">@string.Format("{0:dd-MMM-yyyy}", @m.create_date)</td>
<td style="min-width: 100px;">@m.created_by</td>
<td style="min-width: 100px; width: 100px">@m.Active</td>
</tr>
}
}
</tbody>
</table>
<input type="submit" value="Update" />
</div>
}
</div>
</div>

Dans le code suivant, je suis en train d'essayer d'obtenir la liste proposée à partir de la vue du contrôleur, mais son résultat est null.

 [HttpPost]
public ActionResult bulk_approval(List<registration> model)//here my model shows null, please guide.
{
foreach (var abc in model)
{
}
return View();
}

Qui suit est ma classe.

public class registration
{
public int Id { get; set; }
public string mobile_number { get; set; }
public string account_number { get; set; }
public string customer_name { get; set; }
public int FrequencyId { get; set; }
public bool Active { get; set; }
public string BranchCode { get; set; }
public bool BulkUpload { get; set; }
public string created_by { get; set; }
public DateTime create_date { get; set; }
}
  • L'utilisation de l'indexation (foren boucle) au lieu d'un foreach boucle
  • Pouvez-vous s'il vous plaît partager des exemples de code, merci.
  • Double Possible de Tableau HTML à ADO.NET DataTable
  • Apert pour le fait que vous ne pouvez pas utiliser un foreach boucle (voir la dupe), vos pas, la création de tout pour les contrôles pour modifier vos données (ce qui rend la forme un peu inutile)
InformationsquelleAutor Rauf Abid | 2016-09-21