I have a table than shown one record of my model. for example list of category. i want to create manually row number for this table.
<table class="table table-striped table-bordered table-hover table-full-width dataTable">
  @foreach (var item in Model)
  {   
    <tr>
      <td>
        **I want to Show Row Number Here**
      </td>
      <td>
        @Html.ActionLink(item.Name, "ViewSubCategory", "ProductSubCategory", new { id = item.Id }, null)
      </td>
    </tr>
  }
</table>
Define a counter rowNo and write
@{ int rowNo = 0; }
@foreach (var item in Model) {       
<tr style="background: @classtr;" >
    <td>
        @(rowNo += 1)
    </td>
Define a counter rowNo and write
<table class="table table-striped table-bordered table-hover table-full-width dataTable">
  @{int rowNo;}
  @foreach (var item in Model)
  {   
    <tr>
      <td>
       @rowNo++;
      </td>
      <td>
        @Html.ActionLink(item.Name, "ViewSubCategory", "ProductSubCategory", new { id = item.Id }, null)
      </td>
    </tr>
  }
</table>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With