# Bind Grid to Collections of Dynamic Objects

## Environment

<table>
 <tr>
  <td>Product</td>
  <td>Telerik UI for ASP.NET MVC Grid</td>
 </tr>
 <tr>
  <td>Product version</td>
  <td>2025.1.227</td>
 </tr>
</table>

## Description

How can I bind the Grid to a collection of dynamic objects?

## Solution

You can achieve this requirement using the following implementation:

1. Define the View's model as `IEnumerable<dynamic>` and bind the Grid to this model. Also, configure the Grid for[ Ajax data bidning](https://www.telerik.com/aspnet-mvc/documentation/html-helpers/data-management/grid/binding/ajax-binding).

   ```Razor HtmlHelper
   @model IEnumerable<dynamic>

   @(Html.Kendo().Grid(Model)
       .Name("Grid")
       .DataSource(ds => ds
           .Ajax()
           .Model(m =>
           {
               m.Id("ProductID");
               m.Field("ProductID", typeof(int));
               m.Field("ProductName", typeof(string));
               m.Field("UnitPrice", typeof(decimal));
               m.Field("QuantityPerUnit", typeof(string));
           })
           .Read(r => r.Action("Read", "Home"))
           .Update(u => u.Action("Update", "Home"))
           .Destroy(u => u.Action("Destroy", "Home"))
           .Create(u => u.Action("Create", "Home"))
       )
       ... // Additional configuration
   )
   ```

2. Set up the **Read** Action method of the Grid to retrieve the data:

   ```C#
   public ActionResult Read([DataSourceRequest] DataSourceRequest request)
   {
       return GetView(request);
   }

   private IEnumerable<dynamic> GetData()
   {
       var db = new GridBindingDynamicCollectionEntities();
       return db.Products;
   }

   private JsonResult GetView(DataSourceRequest request)
   {
       return Json(GetData().ToDataSourceResult(request));
   }
   ```

To review the complete example, refer to the ASP.NET MVC project on how to [bind the Telerik UI for ASP.NET MVC Grid to a collection of dynamic objects](https://github.com/telerik/ui-for-aspnet-mvc-examples/tree/master/Telerik.Examples.Mvc/Telerik.Examples.Mvc/Areas/GridBindingDynamicCollection).

## More ASP.NET MVC Grid Resources

* [ASP.NET MVC Grid Documentation](https://www.telerik.com/aspnet-mvc/documentation/html-helpers/data-management/grid/overview)
* [ASP.NET MVC Grid Demos](https://demos.telerik.com/aspnet-mvc/grid/index)
* [ASP.NET MVC Grid Product Page](https://www.telerik.com/aspnet-mvc/grid)
* [Telerik UI for ASP.NET MVC Video Onboarding Course (Free for trial users and license holders)](https://www.telerik.com/aspnet-mvc/documentation/getting-started/video-onboarding)
* [Telerik UI for ASP.NET MVC Forums](https://www.telerik.com/forums/aspnet-mvc)

## See Also

* [Client-Side API Reference of the Grid for ASP.NET MVC](https://docs.telerik.com/kendo-ui/api/ui/grid)
* [Server-Side API Reference of the Grid for ASP.NET MVC](https://docs.telerik.com/aspnet-mvc/api/grid)
* [Telerik UI for ASP.NET MVC Knowledge Base](https://docs.telerik.com/aspnet-mvc/knowledge-base)
