I have a small problem with my table, the buttons and the onclick work fine, but the paramter I want to pass with the click doesn't work the way I expect it to.
here's the code.
<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>
the table is for example P24 in size, Position is always P25 regardless of which button I press, I want the value of Position when that particular cell is created, but Position seems to be set when I click the button, when the whole table is already created and the coordinates have reached the end.
is there a way to achieve the same functionality regarding the click event in blazor, but that stores the parameter in the button rather then fetching the Position parameter's current value when clicking?