I've created a dropdown in my cshtml page:
@( Html.Kendo().DropDownList().Name("ddlCode").OptionLabel("Select Code...").BindTo(@ViewBag.dropDown)
.DataTextField("Title")
.DataValueField("domainCode")
The dropdown is bound upon checking one of the checkboxes on the page.
Upon checkbox check, I call a javascript function and use the following ajax script:
var ddl = $('#ddlCode').data("kendoDropDownList");
$.ajax({
url: "/PP/BindDropDown",
data: {
'Id': paramID
},
dataType: "json",
type: 'POST',
cache: false,
success: function (_data) {
ddl.dataSource.data(_data)
},
error: function () {
//
}
});
The BindDropdown method in the PPController looks like this:
public JsonResult BindDropDown(string ID)
{
List<TEAMS_PP.Entity.correlations> list = new correlation().getDropDownvalues(ID);
ViewBag.dropDown = list;
return Json(list);
}
After binding the dropdown, it shows its items as "Undefined
". How can I resolve this issue?
I am using MVC4 Kendo UI Controls
Entity.Correlations:
public correlations() { }
public correlations(DB.EH_PP_DmainComp item)
{
//this.code = Convert.ToInt32( Convert.ToString(item.domainCode));
this.correlatedText = item.description;
this.codeTitle = item.title;
//Component 1a: Demonstrating Knowledge of Content and Pedagogy
//ArrayList arrCode = new ArrayList();
string[] arrCode = Convert.ToString(item.title).Split(':');
string[] code = Convert.ToString(arrCode[0]).Split(' ');
this.code = Convert.ToString(code[1]);
}
public DB.EH_PP_DmainComp ToDB()
{
var rec = new DB.EH_PP_DmainComp();
return rec;
}
public DB.EH_PP_DmainComp ToDB(DB.EH_PP_DmainComp rec)
{
return rec;
}
}