Bind-value error: Unexpected character encountered while parsing value: C. Path '', line 0, position 0

Hi, 

I am using Combo Box with TValue of a class type, everything works fine until I updated from version 18 to 19. 

If I don't bind the Combo Box value with a property of the same type with TValue, but when I use @bind-value, it keeps throwing the error saying: 

Unexpected character encountered while parsing value: C. Path '', line 0, position 0.


Please advice what is the proper way to bind the complex object value to the Combo Box.

I also attach the sample code and screen shot of full error messages as reference.

Thanks.  



 


Attachment: syncfusion_sample_52de00c9.zip

3 Replies

PO Prince Oliver Syncfusion Team October 6, 2021 11:58 AM UTC

Hi Susanti, 

Thank you for contacting us. 

We tried to recreate your scenario in our end using the shared code snippet. But we were unable to replicate the issue in our end. Please find our test sample using your code 

Please find the test scenario 

  • Bound same class for TValue and TItem as per your code
  • Added a  mock service to retrieve data
  • Added bind-Value to the control and set its value in OnInitializedAsync Life Cycle

Kindly check the above sample in your end and let us know if we missed any step to replicate the issue in our end. If you still face the issue, you can also modify the above test sample to replicate the issue and revert us. 

Regards, 
Prince 



SU Susanti October 6, 2021 11:30 PM UTC

Hi Price,


Attached below is the working sample project that reproduced the problem that I am facing.

In my case, I am using the complex object, and I believe that is what causing the problems, but again, everything was working fine until I update the to version 19.


// There is Logo object nested inside school object,

// without the logo property, everything works fine.


// with Logo property exist:


// 1. When the logo is null, it gives error:

// NullReferenceException


// 2. When the Logo is is assigned value, it gives error:

// Unexpected character encountered while parsing value: B. Path '', line 0, position 0.


Apart from the above problem, there is another problem with the popup is not closing and the combo box crashing, after reselecting new option consecutively for a few times, and when using Filter event there are sometimes 2 popups overlapping.


Thanks beforehand for your time and support.


Attachment: BlazorServerApp5.0_18805b0f.zip



DR Deepak Ramakrishnan Syncfusion Team October 7, 2021 10:49 AM UTC

Hi Susanti, 
 
Thanks for the update. 
 
We have validated you requirement and the actual problem arises in the ‘modifiedDate’ property  inside the school class. 
 
public DateTimeOffset ModifiedDate 
        { 
            get 
            { 
                modifiedDate = DateTimeOffset.Now; 
                return modifiedDate; 
            } 
            set { modifiedDate = value; } 
        } 
 
 
 So, we suggest you to use the code part as like used in the CreatedDate property (Which also yields the same result). We have modified the sample for your reference. 
 
using System; 
using System.Collections.Generic; 
using System.Threading.Tasks; 
 
namespace BlazorServerApp5._0.Data 
{ 
    public class OwnService 
    { 
        public async Task<List<School>> GetDataAsync() 
        { 
            FileInformation logo = new FileInformation() 
            { 
                Id = "715e27e8da16940bdc7a21b2", 
                Name = "Logo1.png", 
                Path = "https://test.com/Logo1.png" 
            }; 
 
            // When the logo is null, it gives error: 
            // NullReferenceException 
 
            // When the Logo is is assigned value, it gives error: 
            // Unexpected character encountered while parsing value: B. Path '', line 0, position 0. 
            List<School> Values = new List<School> { }; 
            Values.Add(new School() 
            { 
                Id = "615e27e8da16940bdc7a21b3", 
                Code = "I1", 
                Name = "Item 1", 
                Logo = logo, 
                StageSets = new string[] { "Stage", "Certificate" }, 
                CreatedDate = new DateTimeOffset(DateTime.Now), 
                ModifiedDate = new DateTimeOffset(DateTime.Now) 
            }); 
            return await Task.FromResult(Values); 
        } 
 
    } 
    public class School 
    { 
        public string Id { get; set; } 
 
        public FileInformation Logo { get; set; } 
 
        public string Code { get; set; } 
 
        public string Name { get; set; } 
 
        public string[] StageSets { get; set; } 
 
        private DateTimeOffset? createdDate; 
        public DateTimeOffset CreatedDate 
        { 
            get { return createdDate ?? DateTimeOffset.Now; } 
            set { createdDate = value; } 
        } 
 
        private DateTimeOffset? modifiedDate; 
        public DateTimeOffset ModifiedDate 
        { 
            get 
            { 
                return modifiedDate ?? DateTimeOffset.Now; 
            } 
            set { modifiedDate = value; } 
        } 
    } 
} 
 
 
 
 
Query : Apart from the above problem, there is another problem with the popup is not closing and the combo box crashing, after reselecting new option consecutively for a few times, and when using Filter event there are sometimes 2 popups overlapping. 
 
We have validated the above query but unfortunately we couldn’t able to reproduce it in our end. Kindly refer the below attached video for your reference. If you still reproducing the issue at your end , Kindly provide us the following details to validate in our end. 
 
1.If any specific replication procedure followed other than followed procedure in video demonstration provided by us. 
2.Also provide the video demonstration of issue reproducing at your end. 
 
The above details will help us to analyze further and provide you the better solution. 
 
Thanks, 
Deepak R. 
 
 
 


Loader.
Up arrow icon