我在cshtml页面中创建了以下下拉列表:
@( Html.Kendo().DropDownList().Name("ddlCode").OptionLabel("Select Code...").BindTo(@ViewBag.dropDown)
.DataTextField("Title")
.DataValueField("domainCode")我正在绑定此下拉列表,以检查我页面上的一个复选框。
在检查复选框时,我调用了javascript函数并编写了如下ajax脚本:
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 () {
//
}
});BindDropdown of PPController包含如下代码:
public JsonResult BindDropDown(string ID)
{
List<TEAMS_PP.Entity.correlations> list = new correlation().getDropDownvalues(ID);
ViewBag.dropDown = list;
return Json(list);
}我的问题是,当下拉列表被绑定时,它将其项显示为"Undefined“,如下所示:

我怎么才能把这个下拉包绑起来?
我使用的是MVC4 Kendo控件。
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;
}
}发布于 2014-06-10 05:52:06
这里发生的是..。
@(Html.Kendo().DropDownList().Name("ddlCode").OptionLabel("Select Code...").BindTo(@ViewBag.dropDown)
.DataTextField("Title")
.DataValueField("domainCode")您正在告诉DropDownList在correlations类中找到Title和domainCode属性。但是,correlations类没有这样的属性。
要完成这项工作,您必须做以下工作之一:
Title和domainCode属性添加到correlations类https://stackoverflow.com/questions/24133622
复制相似问题