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

Can't get databound value of dropdownlist

Thread ID:

Created:

Updated:

Platform:

Replies:

148885 Nov 6,2019 02:22 PM UTC Nov 7,2019 06:49 AM UTC ASP.NET Core 1
loading
Tags: DropDownList
Marvin
Asked On November 6, 2019 02:22 PM UTC

I use javascript in asp.core. I have follow problem:

I have a list wich includes a ID and a Name. I display Name in dropdown list as follow:

  $("#TypeList").ejDropDownList({
                dataSource: dataManagerType,
                fields: { value: "Name", text: "TypeId" },
                enableFilterSearch: true,
                enabled: true,
                change: "GetSpecList",
                validationRules: { required: true },
                validationMessage: { required: 'is required.' },
            });

What I want is to get selected value of dropdown list (Name). 
I tried follow code:

alert(TypeList.value); 

I get only the "ID" not the name. If I use TypeList.Text i get: "undefined"


Keerthana Rajendran [Syncfusion]
Replied On November 7, 2019 06:49 AM UTC

Hi Marvin,  
 
 
Greetings from Syncfusion support.  
 
In DropDownList, text field will be displayed as DropDownList items and value field will be processed internally for selection. You can get the selected value from DropDownList through getSelectedValue()  method using instance of DropDownList. Please refer to the following code 
 
<script> 
    function getValue(args) 
      { 
         var ddl = $("#TypeList").data("ejDropDownList"); 
        alert(ddl.getSelectedValue()); 
         
      } 
</script> 
 
 
You can also get the selected value and text through arguments of change event during selection. Refer the following code 
 
$("#TypeList").ejDropDownList({ 
        dataSource: dataManagerType, 
        fields: { value: "Name", text: "TypeId" }, 
        enableFilterSearch: true, 
        enabled: true, 
        change: "GetSpecList", 
        validationRules: { required: true }, 
        validationMessage: { required: 'is required.' }, 
    }); 
 
    function GetSpecList(args) { 
        console.log(args.selectedText);  // get text 
        console.log(args.selectedValue); //get value 
    } 
 
We have prepared a sample with your code for reference. Please refer to the below given link 
 
 
You can use the same in your asp.net core project. Kindly refer to the below API link of DropDownList 
 
 
Please let us know if you need further assistance on this. 
 
Regards, 
Keerthana. 


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