javascript - internal server error in making a query to populate cascading dropdownlist in ASP MVC -




i have used method in populating cascading dropdownlist use string value in parent dropdown query data populate child dropdown, far i'm not having problems using method until arrived particular controller.

the error being returned in debugging internal server error controller mentioned below. previous dropdownlists fine , javascript getting values, when comes passing title gettrainerlist, returns error based on inspection.

what i'm trying populate dropdownlist names of trainers skilled in particular subject (referred here "qualification").

controller

        public actionresult gettrainerlist(string title) //registered trainers     {         list<trainerregistration> trainerlist = db.trainerregistrations.where(x => x.qualification.title == title)                                             .include(t => t.trainer).include(t => t.qualification)                                             .tolist();          viewbag.traineroptions = new selectlist(trainerlist, "id", "trainer.trainername");         return partialview("traineroptionpartial");     } 

view javascript

 @html.dropdownlistfor(m => m.compendium.qualificationid, new selectlist(""), "--select qualification--", htmlattributes: new { @class = "form-control", @id = "compendiumqualificationddl" })   @html.dropdownlistfor(m => m.trainerregistration.trainerid, new selectlist(""), "--select trainer--", htmlattributes: new { @class = "form-control", @id = "trainerddl" })       $("#compendiumqualificationddl").change(function () {          var title = $("#compendiumqualificationddl option:selected").text();         debugger         $.ajax({              type: "post",             url: "/tenders/gettrainerlist?title=" + title,             contenttype: "html",              success: function (response) {                  $("#trainerddl").empty();                 $("#trainerddl").append(response);             }         }); 

models

   public class trainerregistration {     public int id { get; set; }     public int trainerid { get; set; }     public int qualificationid { get; set; }     public string nttc { get; set; }     public virtual trainer trainer { get; set; }     public virtual qualification qualification { get; set; }     public virtual icollection<tender> tenders { get; set; } } public class qualification {     public int id {get; set;}     public string title { get; set; }     public virtual icollection<trainerregistration> trainerregistrations { get; set; } } public class trainer {     public int id {get; set}     public string trainername     {                 {             return firstname + " " + middlename + ". " + lastname;         }     }     public virtual icollection<trainerregistration> trainerregistrations { get; set; } }  public class tender {     public int id { get; set; }     public int trainerregistrationid { get; set; }     public virtual  trainerregistration trainerregistration { get; set; }  } 





wiki

Comments

Popular posts from this blog

Asterisk AGI Python Script to Dialplan does not work -

python - Read npy file directly from S3 StreamingBody -

kotlin - Out-projected type in generic interface prohibits the use of metod with generic parameter -