Blazor Razden Dropdown Multiple Select - preselect value

Hi,

I'm trying to set the preselected values from another table for the multiselect dropdown.
But I'm getting and object reference error.Is there any Solution to preselect items in the dropdown ?

< <RadzenDropDown Multiple="true" Placeholder="Select..." Data="@bosDistrictslist" TextProperty="DistrictName" ValueProperty="Id"
Style="margin-bottom: 20px; width:200px;" @bind-Value="@selecteddistrictids" Change="@(args => Change(args, "DropDown with multiple selection"))"
@bind-SelectedItem="@_selectedItem">

...
IEnumerable bosDistrictslist;
object selecteddistrictids;
object selectedbosDistricts;
object _selectedItem;

protected override async Task OnInitAsync()
{
BosBoardMotionsList = await DataService.GetBosBoardMotionsAsync();
// Get districts list
bosDistrictslist = await DataService.GetBosDistrictsAsync();

    // Get board members list

    bosMemberslist = await DataService.GetBosmembersAsync();

    selectedbosDistricts = (from dist in bosDistrictslist
                            where dist.Id == 1
                            select dist);

    _selectedItem = selectedbosDistricts;


}

void Change(object value, string name)
{
events.Add(DateTime.Now, $"{name} value changed to {string.Join(",", ((IEnumerable)CustomerIDs))}");
}

Thanks,
Fatima

Hi Fatima,

Here is what I've tried using our demo:

and here is the result


Thank you so much for the reply with sample code.
After changing the Value from integer to String I was able to make it work.
Earlier my selected values were a list of integers.

Thanks,
Fatima