asp.net Razor prevent variables from printing due to counting

80 Views Asked by At

I have the following in a cshtml file

@{
    int rowNumber = 0;
}

Followed by an Html.Grid that stores the number of columns that are generated in the variable:

@Html.Grid(Model.Users).Columns(column =>
{
    column.For(x => x.Username)
}).RowEnd(x => rowNumber++)

However the RowEnd causes the rowNumber to get printed. So I end up with 0123456 printed on the top of the page. How can I prevent that from happening?

Edit: An alternative acceptable answer would be a way to count the number of rows as the Grid is being generated, so that I can make use of it inside each column.For

0

There are 0 best solutions below