0
我目前正在循环访问一个数组,以便使用visual basic在asp.net中填充表。我想填充数组中前9个项目的第一行,然后从计数器的当前位置填充下一行。我只用了2天就可以使用vb,我的当前循环用索引0-9填充每一行,但最好是从10-18开始填充下一行,依此类推。动态循环访问数组
<div class="col-md-10 col-md-offset-1">
<h3 style="text-align:center; padding: 0px;">List of Alerts for Today</h3>
<table id="myTable" class="tablesorter" style="width:100%">
<thead class="finger_hover">
<tr>
<th>Sensor</th>
<th>Date Time</th>
<th>Source IP</th>
<th>Source Port</th>
<th>Destination IP</th>
<th>Destination Port</th>
<th>Protocol</th>
<th>Signature</th>
<th>Signature Class</th>
<th>Count</th>
</tr>
</thead>
<tbody>
@{
int i;
for (i = 0; i < alertForTheDay.Count; i++)
{
@:<tr>
@:
<td>@alertForTheDay[i]</td>
@:
<td>@alertForTheDay[i + 1]</td>
@:
<td>@alertForTheDay[i + 2]</td>
@:
<td>@alertForTheDay[i + 3]</td>
@:
<td>@alertForTheDay[i + 4]</td>
@:
<td>@alertForTheDay[i + 5]</td>
@:
<td>@alertForTheDay[i + 6]</td>
@:
<td>@alertForTheDay[i + 7]</td>
@:
<td>@alertForTheDay[i + 8]</td>
@:
<td>@alertForTheDay[i + 9]</td>
@:</tr>
i = i + 9;
}
}
</tbody>
</table>
</div>
此代码填充下一行与下一集合的数组中的项:在C#我已使用如下所示的代码来实现这一点。下面是VB的代码:
<div class="col-md-10 col-md-offset-1">
<h3 style="text-align:center; padding: 0px;">List of Alerts for Today</h3>
<table id="myTable" class="tablesorter" style="width:100%">
<thead class="finger_hover">
<tr>
<th>Sensor</th>
<th>Date Time</th>
<th>Source IP</th>
<th>Source Port</th>
<th>Destination IP</th>
<th>Destination Port</th>
<th>Protocol</th>
<th>Signature</th>
<th>Signature Class</th>
<th>Count</th>
</tr>
</thead>
<tbody>
@code
Dim increment As Integer = 9
Dim i As Integer
For i = 0 To alertForTheDay.Count Step i + 1
@:<tr>
@:<td>@alertForTheDay(0)</td>
@:<td>@alertForTheDay(1)</td>
@:<td>@alertForTheDay(2)</td>
@:<td>@alertForTheDay(3)</td>
@:<td>@alertForTheDay(4)</td>
@:<td>@alertForTheDay(5)</td>
@:<td>@alertForTheDay(6)</td>
@:<td>@alertForTheDay(7)</td>
@:<td>@alertForTheDay(8)</td>
@:<td>@alertForTheDay(9)</td>
@:</tr>
i = i + 9
Next
End code
</tbody>
</table>
</div>
VB代码填充细胞与精确索引并且即使当我通过代码和数量的变化的步骤,所述细胞总是与所引用的精确值填充。我相信有这样一个简单的方法。请任何帮助表示赞赏。由于
那正是我想要的。像魅力一样工作。感谢您的帮助,我真的很感激:) – BuzzLightYear