AutoComplete component throws error on second page view

Running Syncfusion.Blazor 18.1.0.53 NuGet package in a .NET Core 3.1 solution.

Having populated Autocomplete component with data from OnInitialized() it works as expected. Unfortunately, if I navigate to another page and return to page containing Autocomplete it will crash with following exception (origin is blazor.server.js:15):

Error: System.ArgumentException: Property set method not found.
   at System.Reflection.RuntimePropertyInfo.SetValue(Object obj, Object value, BindingFlags invokeAttr, Binder binder, Object[] index, CultureInfo culture)
   at System.Reflection.RuntimePropertyInfo.SetValue(Object obj, Object value, Object[] index)
   at Syncfusion.Blazor.DropDowns.SfDropDownList`2.updateValues(Dictionary`2 props)
   at Syncfusion.Blazor.DropDowns.SfDropDownList`2.initValue(Dictionary`2 props)
   at Syncfusion.Blazor.DropDowns.SfDropDownList`2.InitialRendered()
   at Syncfusion.Blazor.BaseComponent.InitComponent()
   at Syncfusion.Blazor.BaseComponent.OnAfterRenderAsync(Boolean firstRender)
   at Syncfusion.Blazor.DropDowns.DropDownBase`1.OnAfterRenderAsync(Boolean firstRender)
   at Syncfusion.Blazor.DropDowns.SfDropDownList`2.OnHybridAfterRender(Boolean firstRender)
   at Syncfusion.Blazor.DropDowns.SfDropDownList`2.OnAfterRenderAsync(Boolean firstRender)
   at Syncfusion.Blazor.DropDowns.SfAutoComplete`2.OnAfterRenderAsync(Boolean firstRender)
   at Microsoft.AspNetCore.Components.RenderTree.Renderer.GetErrorHandledTask(Task taskToHandle)

Autocomplete is embedded in following way:
<SfAutoComplete TValue="string" TItem="Address" Placeholder="Enter address" DataSource="@AddressList.Items" Value="@AddressList.SelectedValue" Highlight="true" CssClass="e-input-prepend">
     <AutoCompleteEvents TValue="string" ValueChange="onAddressAutoCompleteChange"></AutoCompleteEvents>
     <AutoCompleteFieldSettings Value="Street"></AutoCompleteFieldSettings>
</SfAutoComplete>

@code {
    private AutoCompleteDto<Address> AddressList;

    protected override void OnInitialized()
    {
        AddressRepository.FindAll().ToList().ForEach(address => AddressList.Items.Add(address));
    }


And here are class definitions:

    public class AutoCompleteDto<T>
    {
        public List<T> Items { get; set; }

        public T Selected { get; set; }

        public string SelectedValue { get; set; }

        public AutoCompleteDto()
        {
            Items = new List<T>();
            SelectedValue = string.Empty;
        }
    }
}

    public class Address : EntityBase<long>
    {
        public Address()
        {  }

        [Required]
        public Guid ExternalId { get; set; }

        [Required]
        public AddressType AddressType { get; set; }

        [Required]
        public string Street { get; set; }

        public User CreatedBy { get; set; }
    }

2 Replies

PG Peder Guzova May 19, 2020 02:19 PM UTC

Bonus question: How do I store entire Address object inside AddressList.Selected when having selected a result from Autocomplete instead of now string value of street inside AddressList.SelectedValue ?

Documentation is not all that great regarding this component. Thanks beforehand!


BC Berly Christopher Syncfusion Team May 22, 2020 01:02 PM UTC

Hi Peder, 
  
Greetings from Syncfusion support. 
  
Query 1: 
Having populated Autocomplete component with data from OnInitialized() it works as expected. Unfortunately, if I navigate to another page and return to page containing Autocomplete it will crash with following exception (origin is blazor.server.js:15): 
 
Response: 
Based on the provided code example, we have prepared the sample and the reported issue is not occurred at our end. Please find the sample from the below link. 
Also, we suspect that the reported issue may be caused due to missing of defining the get and set properties of read-only properties in the application. Please find the common forum link for the reported issue from below.  
Still issue persists, please revert us with issue reproducing sample or modify the sample with reported issue that will help us to check and proceed further at our end.  
Query 2: 
A bonus question: How do I store entire Address object inside AddressList.Selected when having selected a result from Autocomplete instead of now string value of street inside AddressList.SelectedValue ?  
Response: 
Please share elaborate details about the requirement that will help us to check and proceed further from our end.  
Regards, 
Berly B.C 


Loader.
Up arrow icon