This example shows how to databind Telerik TreeView for ASP.NET MVC.
The required steps are:
public ActionResult DataBindingToModel()
{
NorthwindDataContext northwind = new NorthwindDataContext();
return View(northwind.Categories);
}
<%= Html.Telerik().TreeView()
.Name("TreeView")
.BindTo(Model, mappings =>
{
mappings.For<Category>(binding => binding
.ItemDataBound((item, category) =>
{
item.Text = category.CategoryName;
})
.Children(category => category.Products));
mappings.For<Product>(binding => binding
.ItemDataBound((item, product) =>
{
item.Text = product.ProductName;
}));
})
%>