找到我的答案!
解决办法如下:
<table id="cardSetTable" style="overflow-x: scroll;">
@{
var divfactor = (Model.mListCardSets.Count / 6) + (Model.mListCardSets.Count % 6);
int count = 0;
<tr>
@for (int i = 0; i < divfactor; i++)
{
<td>
@Html.HiddenFor(_item => _item.mListCardSets[i].Name)
@Html.HiddenFor(_item => _item.mListCardSets[i].Code)
@Html.CheckBoxFor(_item => _item.mListCardSets[i].IsChecked, new { @class = "checkGroup4", @id = Model.mListCardSets[i].Name })
@Html.DisplayFor(_item => _item.mListCardSets[i].Name)
@Html.Image("~\\Images\\CardSetRarity\\" + Model.mListCardSets[i].Code + "_R.jpeg", Model.mListCardSets[i].Name, new { @class = "nullify", @title = Model.mListCardSets[i].Name })
</td>
}
@{
count++;
}
</tr>
<tr>
@for (int i = 0; i < divfactor; i++)
{
<td>
@Html.HiddenFor(_item => _item.mListCardSets[i + (count * divfactor)].Name)
@Html.HiddenFor(_item => _item.mListCardSets[i + (count * divfactor)].Code)
@Html.CheckBoxFor(_item => _item.mListCardSets[i + (count * divfactor)].IsChecked, new { @class = "checkGroup4", @id = Model.mListCardSets[i + (count * divfactor)].Name })
@Html.DisplayFor(_item => _item.mListCardSets[i + (count * divfactor)].Name)
@Html.Image("~\\Images\\CardSetRarity\\" + Model.mListCardSets[i + (count * divfactor)].Code + "_R.jpeg", Model.mListCardSets[i + (count * divfactor)].Name, new {@class = "nullify", @title = Model.mListCardSets[i + (count * divfactor)].Name })
</td>
}
@{
count++;
}
</tr>
<tr>
@for (int i = 0; i < divfactor; i++)
{
<td>
@Html.HiddenFor(_item => _item.mListCardSets[i + (count * divfactor)].Name)
@Html.HiddenFor(_item => _item.mListCardSets[i + (count * divfactor)].Code)
@Html.CheckBoxFor(_item => _item.mListCardSets[i + (count * divfactor)].IsChecked, new { @class = "checkGroup4", @id = Model.mListCardSets[i + (count * divfactor)].Name })
@Html.DisplayFor(_item => _item.mListCardSets[i + (count * divfactor)].Name)
@Html.Image("~\\Images\\CardSetRarity\\" + Model.mListCardSets[i + (count * divfactor)].Code + "_R.jpeg", Model.mListCardSets[i + (count * divfactor)].Name, new { @class = "nullify", @title = Model.mListCardSets[i + (count * divfactor)].Name })
</td>
}
@{
count++;
}
</tr>
<tr>
@for (int i = 0; i < divfactor; i++)
{
<td>
@Html.HiddenFor(_item => _item.mListCardSets[i + (count * divfactor)].Name)
@Html.HiddenFor(_item => _item.mListCardSets[i + (count * divfactor)].Code)
@Html.CheckBoxFor(_item => _item.mListCardSets[i + (count * divfactor)].IsChecked, new { @class = "checkGroup4", @id = Model.mListCardSets[i + (count * divfactor)].Name })
@Html.DisplayFor(_item => _item.mListCardSets[i + (count * divfactor)].Name)
@Html.Image("~\\Images\\CardSetRarity\\" + Model.mListCardSets[i + (count * divfactor)].Code + "_R.jpeg", Model.mListCardSets[i + (count * divfactor)].Name, new { @class = "nullify", @title = Model.mListCardSets[i + (count * divfactor)].Name })
</td>
}
@{
count++;
}
</tr>
<tr>
@for (int i = 0; i < divfactor; i++)
{
<td>
@Html.HiddenFor(_item => _item.mListCardSets[i + (count * divfactor)].Name)
@Html.HiddenFor(_item => _item.mListCardSets[i + (count * divfactor)].Code)
@Html.CheckBoxFor(_item => _item.mListCardSets[i + (count * divfactor)].IsChecked, new { @class = "checkGroup4", @id = Model.mListCardSets[i + (count * divfactor)].Name })
@Html.DisplayFor(_item => _item.mListCardSets[i + (count * divfactor)].Name)
@Html.Image("~\\Images\\CardSetRarity\\" + Model.mListCardSets[i + (count * divfactor)].Code + "_R.jpeg", Model.mListCardSets[i + (count * divfactor)].Name, new { @class = "nullify", @title = Model.mListCardSets[i + (count * divfactor)].Name })
</td>
}
@{
count++;
}
</tr>
<tr>
@{
var lastRow = divfactor*count;
for (int i = lastRow; i < Model.mListCardSets.Count; i++)
{
<td>
@Html.HiddenFor(_item => _item.mListCardSets[i].Name)
@Html.HiddenFor(_item => _item.mListCardSets[i].Code)
@Html.CheckBoxFor(_item => _item.mListCardSets[i].IsChecked, new { @class = "checkGroup4", @id = Model.mListCardSets[i].Name })
@Html.DisplayFor(_item => _item.mListCardSets[i].Name)
@Html.Image("~\\Images\\CardSetRarity\\" + Model.mListCardSets[i].Code + "_R.jpeg", Model.mListCardSets[i].Name, new { @class = "nullify", @title = Model.mListCardSets[i].Name })
</td>
}
}
</tr>
}
</table>