Second time entering the form to edit the dropdown list is empty.

Hi 

I have a dropdown list that works perfectly fine editing it the first time but when you cancel or submit and go back the dropdown value and list is empty.
Even though the data is still present in all the objects while debugging.

I thought I mentioned that before I upgraded....
I use to have the error : System.ArgumentException: There is no tracked object with id 'XX'. Perhaps the DotNetObjectReference instance was already disposed. (Parameter 'dotNetObjectId')
but that disappeared upgrading to <PackageReference Include="Syncfusion.Blazor" Version="18.2.0.48" />


Here is what my code looks like:

@inject IMathFrenzyLevelGroupRepository mathFrenzyLevelGroupRepository

@using Microsoft.AspNetCore.Authorization

@attribute [Authorize]

 

@if (MathFrenzyLevelHeaderDTO == null)

{

    <p>Loading</p>

}

else

{

    <EditForm Model="MathFrenzyLevelHeaderDTO" OnSubmit="ValidSubmit">

        <DataAnnotationsValidator />

 

        <div class="form-group">

            <div class="control-section">

 

                <div class="content wrapper">

                    <SfDropDownList TValue="int" TItem="MathFrenzyLevelGroupDTO" PopupHeight="230px" Placeholder="Select a Group Level" DataSource="@MathFrenzyLevelGroupList" @bind-Value="@MathFrenzyLevelHeaderDTO.MathFrenzyLevelGroupId">

                        <DropDownListFieldSettings Text=@nameof(MathFrenzyLevelGroupDTO.Name) Value=@nameof(MathFrenzyLevelGroupDTO.Id)></DropDownListFieldSettings>                      

                    </SfDropDownList>

                </div>

            </div>

        </div>


        <button class="btn btn-info m-3" type="submit">Done</button>

        <button class="btn btn-danger m-3" @onclick="Cancel">Cancel</button>

    </EditForm>

}

 

@code {

    [Parameter] public MathFrenzyLevelHeaderDTO MathFrenzyLevelHeaderDTO { get; set; }

    [Parameter] public EventCallback<MathFrenzyLevelHeaderDTO> OnValidSubmit { get; set; }

    [Parameter] public EventCallback OnCancel { get; set; }

    protected List<MathFrenzyLevelGroupDTO> MathFrenzyLevelGroupList;

 

    private async Task LoadMathFrenzyLevelGroups()

    {

        try

        {

            MathFrenzyLevelGroupList = await mathFrenzyLevelGroupRepository.GetMathFrenzyLevelGroups();

        }

        catch (Exception ex)

        {

            Console.WriteLine(ex.Message);

        }

    }

 

    protected override async Task OnInitializedAsync()

    {

        await LoadMathFrenzyLevelGroups();

        await base.OnInitializedAsync();

    }

 

    private async Task ValidSubmit()

    {

        await OnValidSubmit.InvokeAsync(MathFrenzyLevelHeaderDTO);

    }

 

    private async Task Cancel()

    {

        await OnCancel.InvokeAsync(null);

    }

}


3 Replies 1 reply marked as answer

SP Sureshkumar P Syncfusion Team August 17, 2020 12:40 PM UTC

Hi Basil, 
 
Greetings from Syncfusion support. 
 
Based on the provided details, we could not replicate the issues at our end. So, we suggest you to share the code for defined data for the DropDownList component in the page IMathFrenzyLevelGroupRepository that will help us to check and proceed further at our end. Also, share any video demonstration for getting empty data for DropDownList which is also useful to check the issue for us.  
 
Regards, 
Sureshkumar P. 



BB Basil Buwalda August 17, 2020 09:50 PM UTC

Hi 

Here is IMathFrenzyLevelGroupRepository

using EquiAviaLetsLearn.Shared.DTOs;

using System.Collections.Generic;

using System.Threading.Tasks;

 

namespace EquiAviaLetsLearn.Client.Repository

{

    internal interface IMathFrenzyLevelGroupRepository

    {

        Task<List<MathFrenzyLevelGroupDTO>> GetMathFrenzyLevelGroups();

        Task<MathFrenzyLevelGroupDTO> CreateMathFrenzyLevelGroup(MathFrenzyLevelGroupDTO mathFrenzyLevelGroup);

        Task<MathFrenzyLevelGroupDTO> GetMathFrenzyLevelGroup(int id);

        Task<MathFrenzyLevelGroupDTO> UpdateMathFrenzyLevelGroup(MathFrenzyLevelGroupDTO mathFrenzyLevelGroup);

        Task DeleteMathFrenzyLevelGroup(int id);

    }

}

AND the Implementation MathFrenzyLevelGroupRepository

 

using System;

using System.Collections.Generic;

using System.Threading.Tasks;

using EquiAviaLetsLearn.Client.Helpers;

using EquiAviaLetsLearn.Shared.DTOs;

 

namespace EquiAviaLetsLearn.Client.Repository

{

    public class MathFrenzyLevelGroupRepository : BaseRepository, IMathFrenzyLevelGroupRepository

    {

        public MathFrenzyLevelGroupRepository(IHttpService httpService) : base(httpService)

        {

        }

 

        protected override string GetBaseURL()

        {

            return "/api/mathfrenzylevelgroup";

        }

 

        public async Task<List<MathFrenzyLevelGroupDTO>> GetMathFrenzyLevelGroups()

        {

            return await _httpService.GetHelper<List<MathFrenzyLevelGroupDTO>>(GetBaseURL());

        }

 

        public async Task<MathFrenzyLevelGroupDTO> CreateMathFrenzyLevelGroup(MathFrenzyLevelGroupDTO mathFrenzyLevelGroup)

        {

            var response = await _httpService.Post(GetBaseURL(), mathFrenzyLevelGroup);

            if (!response.Success)

            {

                throw new ApplicationException(await response.GetBody());

            }

 

            return (MathFrenzyLevelGroupDTO)response.Response;

        }

 

        public async Task<MathFrenzyLevelGroupDTO> GetMathFrenzyLevelGroup(int id)

        {

            return await _httpService.GetHelper<MathFrenzyLevelGroupDTO>(GetBaseURL() + $"/{id}");

        }

 

        public async Task<MathFrenzyLevelGroupDTO> UpdateMathFrenzyLevelGroup(MathFrenzyLevelGroupDTO mathFrenzyLevelGroup)

        {

            var response = await _httpService.Put(GetBaseURL(), mathFrenzyLevelGroup);

            if (!response.Success)

            {

                throw new ApplicationException(await response.GetBody());

            }

 

            return (MathFrenzyLevelGroupDTO)response.Response;

        }

 

        public async Task DeleteMathFrenzyLevelGroup(int id)

        {

            var response = await _httpService.Delete(GetBaseURL() + $"/{id}");

            if (!response.Success)

            {

                throw new ApplicationException(await response.GetBody());

            }

        }

    }

}

 



SP Sureshkumar P Syncfusion Team August 24, 2020 11:33 AM UTC

Hi Basil, 
 
Thanks for your patience.  
 
Based on your shared information, we have created the sample with async data to load the data source to the dropdownlist component. But we cannot replicate the reported issue from our end.  
 
 
If still you have facing the issue, then if possible, please replicate the reported issue from the above attached sample and share the detailed issue replication procedure. That will help us to provide exact solution from our end. 
 
Regards, 
Sureshkumar P 


Marked as answer
Loader.
Up arrow icon