How to display row number in MVC WebGrid

前端 未结 5 2069
南笙
南笙 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:43

    simply add the following code

    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)
    

    Check this link for more info

    hope this will be helpful to someone

提交回复
热议问题