DataGrid dynamic columns for/foreach

Hi, I want to display a list of string arrays, where each array is a row and array elements are columns in the grid.

<RadzenDataGrid Data="@data">
        @for(var i =0; i < numberOfColumns - 1; i++)
            <RadzenDataGridColumn TItem="string[]">

This displays the last array element in all grid cells (the last value of i, that's why the -1). But if I change the for loop to foreach

@foreach(var i in Enumerable.Range(0, numberOfColumns))

Then it works as expected and displays respective column value in each cell. What is the issue here? I suspect this is something related to Blazor binding but I am not too familiar with how it all works yet.

Check this thread: