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
)
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