c# - The model item passed into the dictionary is of type 'System.Collections.Generic.List`1[TipoDeCanal]', -


i error when passing data controller view:

the model item passed dictionary of type 'system.collections.generic.list`1[tipodecanal]', dictionary requires model item of type tipodecanal'.

     public class tipodecanalescontroller : genericcontroller         {             private unitofwork unitofwork = new unitofwork();              // get: tipodecanales             public actionresult index([datasourcerequest] datasourcerequest request)             {                 //return json(unitofwork.tipodecanalrepository.get(),jsonrequestbehavior.allowget);                 return view(unitofwork.tipodecanalrepository.get());             }   @model ..models.tipodecanal @using ..models @{     viewbag.title = "index"; }  <h2>index</h2>  @(html.kendo().grid<tipodecanal>()     .name("grid")     .columns(columns =>     {         columns.bound(p => p.id);         columns.bound(p => p.nombre).title("nombre");         columns.bound(p => p.descripcion).title("descripcion");     })     .toolbar(toolbar => toolbar.create())     .editable(editable => editable.mode(grideditmode.popup))     .pageable()     .sortable()     .scrollable(scr => scr.height(430))     .filterable()     .datasource(datasource => datasource         .ajax()         .pagesize(20)         .events(events => events.error("error_handler"))         .model(model => model.id(p => p.id))         .create(update => update.action("editingpopup_create", "grid"))         .read(read => read.action("index", "grid"))         .update(update => update.action("editingpopup_update", "grid"))         .destroy(update => update.action("editingpopup_destroy", "grid"))     ) ) <script type="text/javascript">     function error_handler(e) {         if (e.errors) {             var message = "errors:\n";             $.each(e.errors, function (key, value) {                 if ('errors' in value) {                     $.each(value.errors, function () {                         message += + "\n";                     });                 }             });             alert(message);         }     } </script> 

your view requires single object @model ...models.tipodecanal controller action return ienumerable<tipodecanal>

replace @model list<...models.tipodecanal>


Comments

Popular posts from this blog

ruby - Trying to change last to "x"s to 23 -

jquery - Clone last and append item to closest class -

css - Can I use the :after pseudo-element on an input field? -