我有 2 个数组需要传递给并在视图中显示。现在我有:
String[] unactivePanelsHeader = new String[] {"GT5C", "GT5E", "GT5P", "GT5W"};
int[] unactivePanelsValues = new int[4];
//Values for unactivePanelsValues created with a linq query
ViewBag.unactivatedHeader = unactivePanelsHeader;
ViewBag.unactivatedPanels = unactivePanelsValues;
结果随后显示在视图中。
<table>
<tr>
@for (int i = 0; i < 4; i++ )
{
<td>@ViewBag.unactivatedHeader[i]</td>
}
</tr>
<tr>
@for (int i = 0; i < 4; i++ )
{
<td>@ViewBag.unactivatedPanels[i]</td>
}
</tr>
它有效,但我是这个平台的新手,似乎应该有更好的方法。