Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You can create new viewmodel class and add new property to it:</p> <p>View model:</p> <pre><code>public class PersonsViewModel { public List&lt;person&gt; Persons { get; set; } public Int32 TotalCount{ get; set; } } </code></pre> <p>Action:</p> <pre><code> public ActionResult Index() { int result; var model = new PersonsViewModel(); List&lt;person&gt; mn = new List&lt;person&gt;(); mn.Add(new person(1,"john", "adebayo", "shobanjo close jericho")); mn.Add(new person(2, "david", "johnson", "ibada close")); mn.Add(new person(3, "bayo", "olomale", "oluyole estate ringroad")); result = WriteToDb(mn); model.Persons = mn; model.TotalCount = 42; // your variable return View(model); } </code></pre> <p>View:</p> <pre><code>@model PersonsViewModel @{ ViewBag.Title = "Index"; } &lt;h2&gt;Total : @Model.TotalCount&lt;/h2&gt; &lt;p&gt; @Html.ActionLink("Create New", "Create") &lt;/p&gt; &lt;table&gt; &lt;tr&gt; &lt;th&gt; FirstName &lt;/th&gt; &lt;th&gt; LastName &lt;/th&gt; &lt;th&gt; Address &lt;/th&gt; &lt;th&gt;&lt;/th&gt; &lt;/tr&gt; @foreach (var item in Model.Persons) { &lt;tr&gt; &lt;td&gt; @Html.DisplayFor(modelItem =&gt; item.FirstName) &lt;/td&gt; &lt;td&gt; @Html.DisplayFor(modelItem =&gt; item.LastName) &lt;/td&gt; &lt;td&gt; @Html.DisplayFor(modelItem =&gt; item.Address) &lt;/td&gt; &lt;td&gt; @Html.ActionLink("Edit", "Edit", new { id=item.Id }) | @Html.ActionLink("Details", "Details", new { id=item.Id }) | @Html.ActionLink("Delete", "Delete", new { id=item.Id }) &lt;/td&gt; &lt;/tr&gt; } &lt;/table&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload