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.
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Why the getSelectedValue method always returns the value in string, even the value in some other data type? Is there any way to achieve that?

Description

By default, getSelectedValue method is used to retrieve the items value that are selected in the DropDownList. It returns the item value in the “string” data type instead of corresponding data type of the item.

 

Solution

But, using itemValue property, we can get the selected items as it is. But the “itemValue” property is only applicable for Single Selection mode in the DropDownList.

 

In the following example, upon selecting the items in the DropDownList, the change event will be triggered. In the change event, itemValue will returns the selected value in the DropDownList and the returned value will be in its corresponding data type.

 

For reference, we have added the local method called “toType” which receives the selected value from the DropDownList and returns the data type of the value.

 

Please refer the following code snippet.

Javascript

 

 

Article ID: Published Date: Last Revised Date: Platform: Control:
7040 08/02/2016 06/13/2017 JavaScript ejDropDownList
Did you find this information helpful?
Add Comment
You must log in to leave a comment

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