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
close icon

Value not selected

I use your DropDownList like this:

        <ejs-dropdownlist id="country" placeholder="Select" dataSource="Model.BundeslaenderModelJson" value="5"></ejs-dropdownlist>

Model.BundeslaenderModelJson is the following Json:

[{"text":"Zentrale","value":"1"},{"text":"Wien","value":"2"},{"text":"Niederösterreich","value":"3"},{"text":"Oberösterreich","value":"4"},{"text":"Salzburg","value":"5"},{"text":"Tirol","value":"6"},{"text":"Vorarlberg","value":"7"},{"text":"Kärnten","value":"8"},{"text":"Steiermark","value":"9"},{"text":"Burgenland","value":"10"}]

When i load the page nothing is selected.

The value and the text field seems not bind correctly. In the Firefox debugger is see following when i look at the option of the control:


and when i click on an option it looks like this:


Two times the "text". I think there is something wrong?

  • Im Wörterbuch speichern
    • Keine Wortliste für Englisch -> Deutsch...
    • Eine neue Wortliste erstellen...
  • Kopieren

3 Replies

SP Sureshkumar P Syncfusion Team January 13, 2020 12:36 PM UTC

Hi Thomas, 
 
Greetings from Syncfusion support. 
 
We have checked the reported requirement. We would like to let us know that when bind the object type dataSource then you need to use the fields for selecting the value property the object dataSource. Also, text property value will be set to the select element’s innerText and the select element’s text property. Kindly refer the below code,  
 
<ejs-dropdownlist id="country" placeholder="Select" dataSource="@ViewBag.data" value="@ViewBag.val"> 
    <e-dropdownlist-fields text="Vegetable" value="Id"></e-dropdownlist-fields> 
</ejs-dropdownlist> 
 
 
 
Regards, 
Sureshkumar P 



TS Thomas Schinagl January 16, 2020 12:34 AM UTC

Ok thanks. I thought its enough when the datasource have a "value" and a "text" property.


PO Prince Oliver Syncfusion Team January 17, 2020 05:56 AM UTC

Hi Thomas, 

Most welcome. You can refers to our documentation site, if you need any further assistance regarding this. 


We are always happy to assist you. 

Regards, 
Prince 


Loader.
Live Chat Icon For mobile
Up arrow icon