I have a form with about 60 checkboxes of which I have to activate some checkboxes randomly based on a user profile that I acquire from a database. I have the IDs of the checkboxes to select. Is there any way to do that with Blazor?
The first element is a select where I can choose a certain user role for which I receive a list of checkbox IDs that have to be activated for that specific role
<select class="form-control" @bind:event="onInput" @bind="@D5UserTitle" @onchange="PopulateAccessRights">
<option selected disabled>Please select role...</option>
@foreach (var title in Titles) {
<option value="@title.PkId">@title.Jobtitle1</option>
}
</select>
<input type="checkbox" id="sma" />
<input type="checkbox" id="smb" />
<input type="checkbox" id="smc" />
<input type="checkbox" id="smd" />
@code{
protected override async Task OnInitializedAsync()
{
D5Users = await us.GetUsersAsync();
Titles = await us.GetJobTitlesAsync();
ADUsers = await us.GetADUsersAsync();
}
private void PopulateAccessRights()
{
// Here we acquire a list of the IDs of every checkbox to tick for that specific role. The result looks like this: sma;smd;CM_A;CESAR_A;MBKSO_A;OTB_A;VPLUS_A;MW_A;OD_A;XP_A
Every corresponding checkbox must be ticked.
List<string> ConfigurationString = Titles.Where(s => s.PkId == 25).First().ConfigurationString.Split(";").ToList();
// Here's where I'd like to activate the checkboxes
}
}