【发布时间】:2019-11-01 10:09:45
【问题描述】:
我的表格有一个小问题,按钮和 onclick 工作正常,但是我想通过点击传递的参数没有按我预期的方式工作。
这是代码。
<table class="table-spaced table-responsive">
<thead>
<tr>
<th />
@for (int i = 1; i <= Plate.PlateType.NumberOfColumns; i++)
{
<th class="cell_head">@i</th>
}
</tr>
</thead>
<tbody>
@for (int y = 0; y < Plate.PlateType.NumberOfRows; y++)
{
<tr>
<td style="vertical-align:central">
@Helper.RowLetters[y]
</td>
@for (int x = 1; x <= Plate.PlateType.NumberOfColumns; x++, Position = string.Format("{0:c}{1:d2}", Helper.RowLetters[y], x))
{
if (Plate.Compounds.ContainsKey(string.Format("{0:c}{1:d2}", Helper.RowLetters[y], x)))
{
----> <td class="compound"><button type="button" class="compound" @onclick="() => PlateGridClick(Position)" itemprop="@string.Format("{0:c}{1:d2}", Helper.RowLetters[y], x))"/></td>
}
else
{
<td class="no_compound" />
}
}
</tr>
}
</tbody>
</table>
表格的大小例如为 P24,无论我按下哪个按钮,位置始终为 P25,我想要创建该特定单元格时的位置值,但是当我单击按钮时,位置似乎已设置,当整个表格已经创建完毕,坐标已经到达终点。
有没有办法在 blazor 中实现与单击事件相同的功能,但将参数存储在按钮中,而不是在单击时获取 Position 参数的当前值?
【问题讨论】:
标签: c# blazor .net-core-3.0 blazor-server-side