# Model Binding

The Telerik UI Menu enables you to bind it to a hierarchical model.

1. Create a new action method and pass the **Categories** table as the model. The **Categories** has to be associated to the **Products** table.

   ```C#
   public ActionResult Index()
   {
       NorthwindDataContext northwind = new NorthwindDataContext();

       return View(northwind.Categories);
   }
   ```

2. Make your view strongly typed.

   ```Razor
   @model IEnumerable<MvcApplication1.Models.Category>
   ```

3. Add a Menu.

   ```Razor HtmlHelper
   @(Html.Kendo().Menu()
       .Name("menu") // The name of the Menu is mandatory. It specifies the "id" attribute of the widget.
       .BindTo(Model, mappings =>
       {
           mappings.For<Category>(binding => binding // Define the first level of the Menu.
               .ItemDataBound((item, category) => // Define the mapping between the Menu item properties and the model properties.
                   {
                   item.Text = category.CategoryName;
                   })
               .Children(category => category.Products)); // Define which property of the model contains the children.
           mappings.For<Product>(binding => binding
               .ItemDataBound((item, product) =>
               {
                   item.Text = product.ProductName;
               }));
       })
   )
   ```

## See Also

* [Model Binding by the Menu for ASP.NET MVC (Demo)](https://demos.telerik.com/aspnet-mvc/menu/modelbinding)
* [Binding to Custom Attributes by the Menu for ASP.NET MVC (Demo)](https://demos.telerik.com/aspnet-mvc/menu/menu-bind-attributes)
* [Server-Side API](https://www.telerik.com/aspnet-mvc/documentation/api/menu)
