Is it possible to have a multiple select dropdown inside an inline edit datagrid?

Hi,

I have an object called Commission with a Members property which is a List of type Member. I would like to select members of a commission with a multiple select dropdown component. But I can not get it to work.

I tried to add a SelectedMemberIds property to the Commission object with the following code so I have a property with all selected Member Ids which is filled with the current memberid's.

public bool RefreshedIds = false;

   public IEnumerable<string> SelectedMemberIds
        {
            get
            {
                if (!RefreshedIds)
                {
                    if (Members is null)
                    {
                        return Array.Empty<string>();
                    }
                    else
                    {
                                            RefreshedIds = true;
                    SelectedMemberIds = Members.Select(m => m.Id).ToArray();
                    }
                }
                return SelectedMemberIds;
            }
            set
            {
                SelectedMemberIds = value;
            }
        }

This resulted in an Access violation in my code which is not really surprising because it seems like a really weird way to do this. The radzendropdown looks like this.

<RadzenDataGridColumn Width="200px" Property="MemberCount" TItem="Commission" Title="Leden">
                <EditTemplate Context="commission">
                    <RadzenDropDown Multiple="true" AllowClear="true" ValueProperty="Id" Data="@MemberList" @bind-Value="commission.SelectedMemberIds" Name="CommissionMembers" Style="width:100%">
                        <Template Context="member">
                            @(member.FirstName) @(member.LastName)
                        </Template>
                    </RadzenDropDown>
                </EditTemplate>
            </RadzenDataGridColumn>

I am not sure if what I would like to do is possible with Radzen, does anybody know? Otherwise, I am just wasting time thinking about these weird structures.

Your code looks fine. What are the details of the AccessViolationException? It is a rather unusual exception to get considering it involves accessing protected memory.

Thanks for your answer, there was a problem in the way I set up the getter and setter. I changed the code to the following and it kind of works now:

private IEnumerable<string> _SelectedMemberIds { get; set; }

public IEnumerable<string> SelectedMemberIds
{
    get
    {
        if (!RefreshedIds)
        {
            if (Members is null)
            {
                _SelectedMemberIds = Array.Empty<string>();
            }
            else
            {
                _SelectedMemberIds = Members.Select(m => m.Id).ToArray();
            }
            RefreshedIds = true;
        }
        return _SelectedMemberIds;
    }
    set
    {
        _SelectedMemberIds = value;
    }
}

There is only one problem. It does not register the first click. I made breakpoints in the getter at return _SelectedMemberIds; and in the setter at _SelectedMemberIds = value;. When I select an item the first time I can see it sets the _SelectedMemberIds property to the correct value. When I continue the code it breaks at the getter (after setting the value) but now it reads the old value.

Is this because of a parallel implementation? Is there a known solution for this?