[HttpGet] public virtual JsonResult LoadInfo() { var query = _repository.GetInformation(); //Here you return the data. return Json(query, JsonRequestBehavior.AllowGet); }
Then in your view:
<select id="info"></select>
Then you load the drop down using jQuery
function LoadInfo() { $.getJSON("@Url.Action(MVC.ControllerName.MethodName())", null, function (data) { $("#info").empty(); $.each(data, function () { $("#info").append($("<option />").val(this.Id).text(this.Name)); }); }); }
This assumes that Id and Name are properties of your object. You could use ID and Name depending on which drop down you're loading.
Hope this helps,
Liked By
Write Answer
Dynamically populate the drop-down using jQuery in ASP.Net MVC3
Join MindStick Community
You have need login or register for voting of answers or question.
Anurag Sharma
11-Feb-2015