Почему нельзя связать данные с выпадающим списком telerik kendo - PullRequest
0 голосов
/ 17 октября 2019

Я не могу связать данные из моей базы данных с выпадающим списком telerik kendo. Когда я запускаю код, выпадающий список просто показывает пустое, как это, и его нельзя щелкнуть.

enter image description here

Модель

public class CountryModel
    {
        public string CountryCode { get; set; }

        public string CountryDesc { get; set; }
    }

Контроллер

        [HttpGet]
        private ActionResult GetCountry()
        {
            var countryList = _registerBS.GetCountry();
            return Json(countryList, JsonRequestBehavior.AllowGet);
        }

Вид

                @(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;
        }
...