Home > DeveloperSection > Forums > How to bind dropdown list using knockout.js in mvc entity framework
Ankit Singh

Total Post:341

Posted on    October-15-2015 2:34 AM

 ASP.NET MVC Mvc4  Entity Framework  Knockout.js 

 1 Reply(s)
 2352  View(s)
Rate this:
can anyone please help me solve this problem

Ankit Singh

Total Post:341

Posted on    October-15-2015 3:12 AM

<!DOCTYPE html>



    <meta name="viewport" content="width=device-width, initial-scale=1">

    <script src="/Scripts/jquery-2.1.4.min.js"></script>

  <script src="/Scripts/knockout-3.3.0.js"></script>



<div id="demo">

<select class="form-control Dropdown" id="brand" data-bind="options:Brands, optionsText:BrandName,optionsValue:'Id',

value:BrandId, optionsCaption: 'All'">




function viewModel() {

    var self = this;

    self.Brands = ko.observableArray();

    self. BrandId = ko.observable();

    $.getJSON("/Home/BrandList ", function (data) {

        self.Brands (data);



$(function () {

    var NewViewModel = new viewModel ();

    ko.applyBindings(NewViewModel, document.getElementById("demo"));






public class HomeController : Controller


public JsonResult BrandList ()


var data = db.Database.SqlQuery<Manufacturers>(@"SELECT DISTINCT BrandName,Id

 FROM Brand_table").ToList();

return Json(data, JsonRequestBehavior.AllowGet);



Modified On Oct-15-2015 03:13:19 AM

Don't want to miss updates? Please click the below button!

Follow MindStick