We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

DropDownList Not Populating, Disconnecting Debug Session

Thread ID:

Created:

Updated:

Platform:

Replies:

147313 Sep 5,2019 04:02 PM UTC Sep 9,2019 04:10 AM UTC Blazor 3
loading
Tags: Dropdown List
ITninja
Asked On September 5, 2019 04:02 PM UTC

The DropDownList component is populated with a simple List<string> and bound to an object, but as soon as I click on the dropdown it immediately spits out an error in the browser. I've tried adding in TValue="string" and TValue="object" with no luck. I've also tried binding to an empty string instead of an object for the bind-Value and didn't have any luck.


<EjsDropDownList Placeholder="Field Type" FloatLabelType="FloatLabelType.Auto" DataSource="@FieldTypes"
@bind-Value="@DocumentFields.FieldTypeString" ShowClearButton="false"></EjsDropDownList>


Uncaught (in promise) Error: System.InvalidCastException: Unable to cast object of type 'Newtonsoft.Json.Linq.JValue' to type 'Newtonsoft.Json.Linq.JObject'.
   at Syncfusion.EJ2.Blazor.BlazorIdJsonConverter.WriteJson(JsonWriter writer, Object value, JsonSerializer serializer)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.SerializeConvertable(JsonWriter writer, JsonConverter converter, Object value, JsonContract contract, JsonContainerContract collectionContract, JsonProperty containerProperty)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.SerializeValue(JsonWriter writer, Object value, JsonContract valueContract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerProperty)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.SerializeList(JsonWriter writer, IEnumerable values, JsonArrayContract contract, JsonProperty member, JsonContainerContract collectionContract, JsonProperty containerProperty)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.SerializeValue(JsonWriter writer, Object value, JsonContract valueContract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerProperty)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.Serialize(JsonWriter jsonWriter, Object value, Type objectType)
   at Newtonsoft.Json.JsonSerializer.SerializeInternal(JsonWriter jsonWriter, Object value, Type objectType)
   at Newtonsoft.Json.JsonSerializer.Serialize(JsonWriter jsonWriter, Object value, Type objectType)
   at Newtonsoft.Json.JsonConvert.SerializeObjectInternal(Object value, Type type, JsonSerializer jsonSerializer)
   at Newtonsoft.Json.JsonConvert.SerializeObject(Object value, Type type, Formatting formatting, JsonSerializerSettings settings)
   at Newtonsoft.Json.JsonConvert.SerializeObject(Object value, Formatting formatting, JsonSerializerSettings settings)
   at Syncfusion.EJ2.Blazor.BaseComponent.DataProcess(String dataManager, String key)
--- End of stack trace from previous location where exception was thrown ---
   at Microsoft.JSInterop.DotNetDispatcher.InvokeSynchronously(String assemblyName, String methodIdentifier, Object targetInstance, String argsJson)
   at Microsoft.JSInterop.DotNetDispatcher.BeginInvoke(String callId, String assemblyName, String methodIdentifier, Int64 dotNetObjectId, String argsJson)
    at Object.endInvokeDotNetFromJS (https://localhost:44325/_framework/blazor.server.js:8:28586)
    at e.<anonymous> (https://localhost:44325/_framework/blazor.server.js:8:103179)
    at https://localhost:44325/_framework/blazor.server.js:1:19148
    at Array.forEach (<anonymous>)
    at e.invokeClientMethod (https://localhost:44325/_framework/blazor.server.js:1:19119)
    at e.processIncomingData (https://localhost:44325/_framework/blazor.server.js:1:17165)
    at e.connection.onreceive (https://localhost:44325/_framework/blazor.server.js:1:10276)
    at WebSocket.i.onmessage (https://localhost:44325/_framework/blazor.server.js:1:38027)

Gopi Govindasamy [Syncfusion]
Replied On September 6, 2019 11:33 AM UTC

Hi Ozzie,  

Greetings for Syncfusion support. 

Currently, we didn’t provide support to pass data source as simple primitive types. Already, we have considered it as bug in our end. We will fix this issue and will be included in our upcoming release which is scheduled on mid of September 2019. You can track the status of the reported feature from the below feedback link. 


Until, we suggest to use the datasource as list<object> key-value pair. Please find the code snippet and sample for your reference.  

@using Syncfusion.EJ2.Blazor.Inputs 
@using Syncfusion.EJ2.Blazor.DropDowns 
 
<h6>DropDownList</h6> 
 
<EjsDropDownList TValue="string" Placeholder="Field Type" FloatLabelType="FloatLabelType.Auto" DataSource="@Country" @bind-Value="@FieldTypeString" ShowClearButton="false"> 
    <DropDownListFieldSettings Text="Name" Value="Code"></DropDownListFieldSettings> 
</EjsDropDownList> 
 
@code{ 
    private bool enable { get; set; } = false; 
    public string FieldTypeString { get; set; } = "BM"; 
    public class Countries 
    { 
        public string Name { get; set; } 
        public string Code { get; set; } 
    } 
    List<Countries> Country = new List<Countries> 
{ 
        new Countries() { Name = "Australia", Code = "AU" }, 
        new Countries() { Name = "Bermuda", Code = "BM" }, 
        new Countries() { Name = "Canada", Code = "CA" }, 
        new Countries() { Name = "Cameroon", Code = "CM" }, 
    }; 
} 

We have prepared sample based on your requirement and download it from the below location. 

Regards, 
Gopi G. 


ITninja
Replied On September 6, 2019 03:08 PM UTC

That works perfectly for now, thank you for the timely response! Looking forward to the coming updates!

Gopi Govindasamy [Syncfusion]
Replied On September 9, 2019 04:10 AM UTC

Hi Ozzie 

Thanks for your update. We will intimate you, once the patch got released. 

Regards, 
Gopi G. 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon