
Below example showing you how to add the row number in WebGrid.
You just need add the following script inside the grid columns.
grid.Column(header: "No.", format: item => item.WebGrid.Rows.IndexOf(item) + 1 + Math.Round(Convert.ToDouble(grid.TotalRowCount / grid.PageCount) / grid.RowsPerPage) * grid.RowsPerPage * grid.PageIndex)
The completed WebGrip example as below:
@{ var grid = new WebGrid(@Model, @grid.GetHtml( columns: new [] { grid.Column(header: "No.", format: item => item.WebGrid.Rows.IndexOf(item) + 1 + Math.Round(Convert.ToDouble(grid.TotalRowCount / grid.PageCount) / grid.RowsPerPage) * grid.RowsPerPage * grid.PageIndex), grid.Column("Title"), grid.Column("Date") } }