Model view controller 为什么不能将数据绑定到telerik剑道下拉列表
我无法将数据库中的数据绑定到telerik剑道下拉列表。 当我运行代码时,下拉列表像这样显示为空,无法单击 模型 控制器Model view controller 为什么不能将数据绑定到telerik剑道下拉列表,model-view-controller,kendo-ui,telerik,Model View Controller,Kendo Ui,Telerik,我无法将数据库中的数据绑定到telerik剑道下拉列表。 当我运行代码时,下拉列表像这样显示为空,无法单击 模型 控制器 [HttpGet] private ActionResult GetCountry() { var countryList = _registerBS.GetCountry(); return Json(countryList, JsonRequestBehavior.Allow
[HttpGet]
private ActionResult GetCountry()
{
var countryList = _registerBS.GetCountry();
return Json(countryList, JsonRequestBehavior.AllowGet);
}
看法
与数据库通信的逻辑
public IEnumerable<CountryModel> GetCountry()
{
var query = (from country in _countryRepo.GetAllActive()
select new CountryModel
{
CountryCode = country.Country_CODE,
CountryDesc = country.Country_DESC
});
return query;
}
public IEnumerable GetCountry()
{
var query=(来自_countryRepo.GetAllActive()中的国家)
选择新的CountryModel
{
CountryCode=country.country\u代码,
CountryDesc=country.country\u DESC
});
返回查询;
}
JavaScript控制台上有错误吗?调试到什么程度了?打控制器?填写清单?控制台错误?没有更多信息的可能性太多了。
@(Html.Kendo().DropDownList()
.Name("country")
.OptionLabel("hello")
.DataTextField("CountryDesc")
.DataValueField("CountryCode")
.DataSource(source =>
{
source.Read(read =>
{
read.Action("GetCountry", "Register");
});
})
)
public IEnumerable<CountryModel> GetCountry()
{
var query = (from country in _countryRepo.GetAllActive()
select new CountryModel
{
CountryCode = country.Country_CODE,
CountryDesc = country.Country_DESC
});
return query;
}