2013-03-25 2 views
0

Я пытаюсь заполнить выпадающий список для использования в моей сетке Kendo с помощью Editor Templates.Kendo Editor Templates (Grid)

Мои StatesEditor.cshtml содержит:

@(Html.Kendo().DropDownList() 
.Name("State") 
.DataValueField("StateID") 
.DataTextField("ShortName") 
.BindTo((System.Collections.IEnumerable)ViewData["states"])) 

В моем контроллере у меня есть:

public ActionResult Index() 
    { 
     var db = new ACoreEntities(); 
     db.Configuration.ProxyCreationEnabled = false; 
     var states = db.StateLookups; 

     var stateList = states.Select(state => state.ShortName); 

     ViewData["states"] = stateList; 


     return View("~/Views/System/PMarkup/Index.cshtml"); 
    } 

В моей фактической сетке, когда я нажимаю кнопку «Изменить» для строки я получаю DropDownList который содержит 51 'undefined' записей.

+0

https://kendoeditortemplate.codeplex.com/ –

ответ

1

Я в конечном итоге создать государственную модель, то в моем ActionResult я изменил мой код:

ViewData["states"] = new ACoreEntities() 
      .StateLookups 
      .Select(s => new State 
      { 
       Id = s.StateID, 
       ShortName = s.ShortName 
      }) 
      .OrderBy(s => s.ShortName);