none
collect number of record in the table RRS feed

  • Question

  • could you please help me?

    i'm beginer in VS2017 . i need to add a statistec table to count the number of person in the table in my DB according to the gender and another statistic table to count people by GOV.

    this is the controller 

      public class PeopleController : Controller
        {
            private Database1Entities db = new Database1Entities();

            // GET: People
            public ActionResult Index()
            {
                var people = db.People.Include(p => p.gender1).Include(p => p.Gov1);
                return View(people.ToList());
            }

    this is the view

    @model IEnumerable<mvc_grouping.Models.Person>

    @{
        ViewBag.Title = "Index";
    }

    <h2>Index</h2>

    <p>
        @Html.ActionLink("Create New", "Create")
    </p>
    <table class="table">
        <tr>
            <th>
                @Html.DisplayNameFor(model => model.Name)
            </th>
            <th>
                @Html.DisplayNameFor(model => model.gender1.gender1)
            </th>
            <th>
                @Html.DisplayNameFor(model => model.Gov1.Gov1)
            </th>
            <th></th>
        </tr>

    @foreach (var item in Model) {
        <tr>
            <td>
                @Html.DisplayFor(modelItem => item.Name)
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.gender1.gender1)
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.Gov1.Gov1)
            </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>
    }

    </table>

    this is the model

    I try to develop a view like this foto

     
    Friday, March 13, 2020 3:35 PM