如何每 10 行自动在 table 中添加一个新行?

How can I add a new row in a table every 10 rows, automatically?

我有一个 table 从具有 foreach 的模型获取数据,在剃刀视图中。我想每 10 行添加一个新行,我该怎么做?

编辑

    <tbody>

    @foreach (var context in sortedData)
    {

        @for (int i = 1; i % 10 == 0;i++)
        {
            <tr>
                <td>
                    new row

                </td>
            </tr>
            
        }
        <tr>
            <td>
                @context.Id
            </td>
            <td>@context.CantidadElegida</td>
            <td>@context.Item</td>
            <td>@String.Format("RD${0:f2}", @context.Price)</td>
            <td>@String.Format("RD${0:f2}", @context.Reposition)</td>
            <td>@String.Format("RD${0:f2}", @context.SubTotal)</td>

        </tr>

    }
</tbody>

看来您正在寻找这个。

int count=1;
 @foreach (var context in sortedData)
    {

        if ( count % 10 == 0)
        {
            <tr>
                <td>
                    new row

                </td>
            </tr>
            
        }
        <tr>
            <td>
                @context.Id
            </td>
            <td>@context.CantidadElegida</td>
            <td>@context.Item</td>
            <td>@String.Format("RD${0:f2}", @context.Price)</td>
            <td>@String.Format("RD${0:f2}", @context.Reposition)</td>
            <td>@String.Format("RD${0:f2}", @context.SubTotal)</td>

        </tr>

count++;
    }

这个怎么样:

int count=1;
 @foreach (var context in sortedData)
    {

        if ( count++ % 10 == 0)
        {
            <tr>
                <td>
                    new row

                </td>
            </tr>
            
        }
        <tr>
            <td>
                @context.Id
            </td>
            <td>@context.CantidadElegida</td>
            <td>@context.Item</td>
            <td>@String.Format("RD${0:f2}", @context.Price)</td>
            <td>@String.Format("RD${0:f2}", @context.Reposition)</td>
            <td>@String.Format("RD${0:f2}", @context.SubTotal)</td>

        </tr>


    }