I've spent too many hours trying to accomplish something that should be very simple, so reaching out to this group. I'm simply trying to update the value of a property of a Blazor form but it doesn't execute the code--it only renders the code on the browser page.
I'm trying to set the variable priorWorkspace to the value of rpt.WorkspaceName as @priorWorkspace = @rpt.WorkspaceName but it doesn't work and the rpt.WorkspaceName is rendered.
Obviously, I'm new at this, so be nice. :-)
<table >
<thead>
<tr>
<th>Select</th>
<th>Workspace</th>
<th>Report Name</th>
<th>Report Desc</th>
</tr>
</thead>
<tbody>
@foreach (var rpt in rptObj)
{
<tr>
@if (@priorWorkspace == @rpt.WorkspaceName)
{
<td></td>
<td>@rpt.WorkspaceName</td>
<td>@rpt.ReportName</td>
<td>@rpt.ReportDesc</td>
}
else
{
<td><input type="checkbox" value="@rpt.WorkspaceName" checked="@isChecked" @onchange="eventArgs => { CheckboxChanged(rpt, eventArgs.Value); }"></td>
<td>@rpt.WorkspaceName</td>
<td>@rpt.ReportName</td>
<td>@rpt.ReportDesc</td>
}
</tr>
<code>@priorWorkspace = @rpt.WorkspaceName</code>
}
</tbody>
</table>
@code {
public string priorWorkspace = "";
List<PowerBIWorkspace> rptObj;
}
CodePudding user response:
I think this is what you want. I didn't test it.
@{
string priorWorkspace = "";
foreach (var rpt in rptObj)
{
<tr>
@if (priorWorkspace == rpt.WorkspaceName)
{
<td></td>
<td>@rpt.WorkspaceName</td>
<td>@rpt.ReportName</td>
<td>@rpt.ReportDesc</td>
}
else
{
<td><input type="checkbox" value="@rpt.WorkspaceName" checked="@isChecked" @onchange="eventArgs => { CheckboxChanged(rpt, eventArgs.Value); }"></td>
<td>@rpt.WorkspaceName</td>
<td>@rpt.ReportName</td>
<td>@rpt.ReportDesc</td>
}
</tr>
priorWorkspace = rpt.WorkspaceName;
}
}
@code {
//public string priorWorkspace = "";
List<PowerBIWorkspace> rptObj;
}