How to display row number in MVC WebGrid

前端 未结 5 2074
南笙
南笙 2021-01-03 07:15

I want to have a column as row number in MVC WebGrid. How can I do it?

5条回答
  •  旧巷少年郎
    2021-01-03 07:34

        @{
        int i=0;
    foreach (var item in Model) {
        
        
        @i
        
            
                @Html.DisplayFor(modelItem => item.Expense)
            
            
                @Html.ActionLink("Edit", "Edit", new { id=item.Id }) |
                @Html.ActionLink("Delete", "Delete", new { id = item.Id }, new { onclick = "return confirm('Are you sure you wish to delete this record?');" })
    
            
        
        i++;
    }
    }
    

    Try this

提交回复
热议问题