Splitting foreach in a table

前端 未结 1 811
醉酒成梦
醉酒成梦 2020-12-22 12:59

As of right now my table looks like this:

But I want to split the foreach to have it look something like this

Is possible to do this?

And

相关标签:
1条回答
  • 2020-12-22 13:55

    You can use the following code to generate rows containing 9 columns

    @{var counter = 1; }
    <tr>
      @foreach (var date in ViewBag.MissingDays)
      {
        var isoDate = date.ToString("yy-MM-dd");
        <td><a href="javascript:SetDate('@isoDate');">@isoDate</a></td>
        if (counter % 9 == 0)
        {
          @:</tr><tr> // end current row and begin new one
        }
        counter++;
      }
    </tr>
    
    0 讨论(0)
提交回复
热议问题