【发布时间】:2014-06-10 05:38:01
【问题描述】:
我在 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 () {
//
}
});
PPController 的BindDropdown 包含如下代码:
public JsonResult BindDropDown(string ID)
{
List<TEAMS_PP.Entity.correlations> list = new correlation().getDropDownvalues(ID);
ViewBag.dropDown = list;
return Json(list);
}
我的问题是当下拉列表被绑定时,它的项目显示为“Undefined”,如下所示:
如何绑定这个下拉菜单???
我正在使用 MVC4 Kendo UI 控件
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;
}
}
【问题讨论】:
-
TEAMS_PP.Entity.correlations是什么? -
那只是一个分配属性的类
-
@Leo 我已经在我的问题中更新了它
标签: c# javascript .net ajax asp.net-mvc-4