I want to have a column as row number
in MVC WebGrid. How can I do it?
That's a really nice approach, but when you use sorting or paging your RowNumber
values won't start from 1 on the page.
In my project I had a case where I needed to know an index of the row independently of WebGrid's paging / sorting and I came across the following solution:
grid.Column(
Header: "RowNumber",
Format: item => item.WebGrid.Rows.IndexOf(item) + 1
)