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