Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
Hi,
I have a table and in the first column i want the number of the item. Example: for the first item i want the number 1 in the column, for the seconds item i want the number 2 in the column...
How can this be done?
This is my code so far:
@foreach (var childPage in Table){ <section class="section"> <div class="container"> <div class="row mb30"> <div class="col-sm-12"> <h2 class="section-title-2">@childPage.title</h2> <div class="table-responsive"> <table class="table table-hover custom-table"> <thead> <tr> <th>#</th> <th>Product</th> <th>Qunatity</th> <th>Total</th> </tr> </thead> <tbody> @foreach (var itemInTable in childPage.Children){ <tr> <td>@itemInTable.Count</td> <td class="text-primary">@itemInTable.tableItemName</td> <td>@itemInTable.tableItemAmount</td> <td>@itemInTable.tableItemTotal</td> </tr> } </tbody> </table> </div> </div> </div> </div> </section> }
So the itemInTable.Count should be the number.
Kind regards, Robert
A simple solution would be doing this:
@{ var count = 1; } @foreach (var itemInTable in childPage.Children){ <tr> <td>@cout</td> <td class="text-primary">@itemInTable.tableItemName</td> <td>@itemInTable.tableItemAmount</td> <td>@itemInTable.tableItemTotal</td> </tr> count++; }
Dave
Well that's looks easy indeed :D
Thanks!
is working on a reply...
This forum is in read-only mode while we transition to the new forum.
You can continue this topic on the new forum by tapping the "Continue discussion" link below.
Continue discussion
Counting number of items
Hi,
I have a table and in the first column i want the number of the item. Example: for the first item i want the number 1 in the column, for the seconds item i want the number 2 in the column...
How can this be done?
This is my code so far:
So the itemInTable.Count should be the number.
Kind regards, Robert
A simple solution would be doing this:
Dave
Well that's looks easy indeed :D
Thanks!
is working on a reply...
This forum is in read-only mode while we transition to the new forum.
You can continue this topic on the new forum by tapping the "Continue discussion" link below.