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. Image for the cookie policy date

DropDownList Not Populating, Disconnecting Debug Session

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)

3 Replies

GG Gopi Govindasamy Syncfusion Team 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. 



IT ITninja September 6, 2019 03:08 PM UTC

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


GG Gopi Govindasamy Syncfusion Team 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. 


Loader.
Live Chat Icon For mobile
Up arrow icon