Welcome to the Blazor feedback portal. We’re happy you’re here! If you have feedback on how to improve the Blazor, we’d love to hear it!>
Thanks for joining our community and helping improve Syncfusion products!
IList<Role> AvailableRolesList { get; set; } = new List<Role>();
IList<int> CurrentUserRolesList { get; set; } = new List<int>();
protected override async Task OnInitializedAsync() {
AvailableRolesList = await _Roles.GetRoles(false);
}
<SfMultiSelect TValue="IList<int>" TItem="Role" @bind-Value="CurrentUserRolesList" DataSource="@AvailableRolesList" Mode="VisualMode.Checkbox">
<MultiSelectFieldSettings Text="RoleName" Value="ID"></MultiSelectFieldSettings>
</SfMultiSelect>
foreach (UserRole role in user.Roles) { CurrentUserRolesList.Add(role.ID);}
When submitting the form, the following piece of code throws an error for "Object reference not set to an instance of an object", in reference to CurrentUserRolesList in the foreach definition.
foreach (int role in CurrentUserRolesList) { ....
}