If the multiselect component was not shown after first render (the "if" statement is false so multiselect was not added to layout) then if we want to show it later (make "if" statement true and add multiSelect to layout) it will have no records.
There are two exactly same multiselects, but second is inside "if" statement and was shown after button click.
<SfButton OnClick="@((_) => show = true)">Show</SfButton>
@if (show)
{
<SfMultiSelect ID="NameMultiSelect" @bind-Value="@selectedNames" Mode="VisualMode.CheckBox" TValue="string[]" DataSource="@names">
</SfMultiSelect>
}
@code
{
private bool show = false;
private string[] selectedNames;
private string[] names;
protected override async Task void OnInitializedAsync()
{
await base.OnInitializedAsync();
names = new string[] { "A", "B" };
}
}