This question is locked. New answers and comments are not allowed.
Hello!
I saw in another post that it was possible to bind to a dynamic object < http://www.telerik.com/community/forums/aspnet-mvc/grid/dynamic-type-with-grid.aspx >.
Does it only work with Razor? Because when i try to use it with the asp.net view engine i get the following error:
RuntimeBinderException
'object' does not contain a definition for 'Text'
This is the view:
and the controller:
When i debug, i can clearly see that the model contains an object that looks like a list with Text/Id elements.
I saw in another post that it was possible to bind to a dynamic object < http://www.telerik.com/community/forums/aspnet-mvc/grid/dynamic-type-with-grid.aspx >.
Does it only work with Razor? Because when i try to use it with the asp.net view engine i get the following error:
RuntimeBinderException
'object' does not contain a definition for 'Text'
This is the view:
<%@ Page Title="" Language="C#" Inherits="System.Web.Mvc.ViewPage<IEnumerable<dynamic>>" %><%= Html.Telerik().Grid<dynamic>(Model) .Name("Test") .Columns(columns => { columns.Bound("Text"); columns.Bound("Id"); }) .DataBinding(dataBinding => dataBinding.Ajax().Select("_BasicDropdownGridBinding", "Grid")) .EnableCustomBinding(true) .Pageable(paging => paging.Total(ViewBag.ItemCount ?? 0).PageSize(10)) .Sortable() %>and the controller:
public ActionResult BasicDropdownGrid(){ IEnumerable<dynamic> data = _BasicDropdownGridGetData(new GridCommand { PageSize = 10 }); ViewBag.ItemCount = 100; return View(data);}[GridAction(EnableCustomBinding = true)]public ActionResult _BasicDropdownGridBinding(GridCommand command){ IEnumerable<dynamic> data = _BasicDropdownGridGetData(command); return View(new GridModel { Data = data, Total = 100 });}private IEnumerable<dynamic> _BasicDropdownGridGetData(GridCommand command){ IEnumerable<Item> data = dbGetItems((command.Page - 1), command.PageSize); return data.Select(x => new { Id = x.Id, Text = x.Text }).ToList();}When i debug, i can clearly see that the model contains an object that looks like a list with Text/Id elements.