This is a migrated thread and some comments may be shown as answers.

[Solved] Dynamic objects

1 Answer 131 Views
Grid
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Mende
Top achievements
Rank 1
Mende asked on 28 Dec 2010, 02:11 PM
Hello,

I want to bind the Grid to dynamic objects like in this page: http://blogs.telerik.com/rosenkonstantinov/posts/10-11-12/binding_to_a_collection_of_dynamic_objects_with_grid_extension_for_asp_net_mvc.aspx

Basic example that does not work:

Controller code
public class OrderController : Controller
        public ActionResult Index()
        {
            BaseEntities context;
 
            context = new BaseEntities ();
 
            var orders = ((from order in context.Orders
            select new
            {
                reference = Order.reference
            }
            ));       
            return View(orders);
        }
}

View code (Razor engine):
@using Telerik.Web.Mvc.UI
@model IEnumerable<dynamic>
 
 
@(
    Html.Telerik().Grid(Model).Name("Grid")
                .DataKeys(dataKeys => dataKeys.Add("reference"))
                .Columns(columns =>
                {
                    columns.Bound("reference");
               })
                .Pageable()
                .Sortable()
                .Groupable()
                .Filterable()
)

"Orders" is correctly mapped in the Entity Model and has a property "reference".

But when executing this page, I get the error message:

Invalid property or field - 'reference' for type: Object


So why this code does not work?
Thank you in advance for your answer.

1 Answer, 1 is accepted

Sort by
0
alex
Top achievements
Rank 1
answered on 08 Dec 2011, 01:20 PM
Hi. Are you fix it? I have similar problem with dynamic
Tags
Grid
Asked by
Mende
Top achievements
Rank 1
Answers by
alex
Top achievements
Rank 1
Share this question
or