)
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

How to bind JSON data in the DropDownList from the client side?

Platform: ASP.NET MVC |
Control: DropDownList |
Published Date: July 6, 2015 |
Last Revised Date: May 8, 2019

Description

Binding the list items as JSON data to the DropDownList from the client side.

Solution

You can bind the list of values into the DropDownList by using the dataSource property of the DropDownList. This is explained in the following code example.

 

CSHTML

@Html.EJ().DropDownList(“bikeList”).DropDownListFields(df => df.ID(“empid”).Text(“text”)).ClientSideEvents(e => e.Create(“onCreate”))
<script>
    function onCreate() {
            BikeList = [
                  { empid: “bk1”, text: “Apache RTR” }, { empid: “bk2”, text: “CBR 150-R” }, { empid: “bk3”, text: “CBZ Xtreme” },
                  { empid: “bk4”, text: “Discover” }, { empid: “bk5”, text: “Dazzler” }, { empid: “bk6”, text: “Flame” },
                  { empid: “bk7”, text: “Fazzer” }, { empid: “bk8”, text: “FZ-S” }, { empid: “bk9”, text: “Pulsar” },
                  { empid: “bk10”, text: “Shine” }, { empid: “bk11”, text: “R15” }, { empid: “bk12”, text: “Unicorn” }
            ];
            var data1 = $(“#bikeList”).data(“ejDropDownList”); //initializes the Dropdownlist.
            data1.option(“dataSource”, BikeList);
    }
</script>

 

2X faster development

The ultimate ASP.NET MVC UI toolkit to boost your development speed.
ADD COMMENT
You must log in to leave a comment

Please sign in to access our KB

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

Up arrow icon

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