This question is locked. New answers and comments are not allowed.
Hi, I'm trying to bind to a custom model. I using 'Razor' with 'Visual basic'.
The example given on the website tells me to use
<%= Html.Telerik().Menu()
.Name("Menu")
.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;
}));
})
My code in Index.vbhtml is :
@imports Telerik.Web.Mvc.UI
@ModelType System.Web.Mvc.ViewUserControl(Of MvcApplication3.MvcApplication3.Models.MenuViewItems)
@Html.Telerik().Menu().Name("MainMenu").BindTo(Model.MenuItemsCategory, Sub(mapping) mapping.[For](Of [Category])(Sub(binding) binding.ItemDataBound(Sub(item As Telerik.Web.Mvc.UI.MenuItem, o As Category) item.Visible = True)))
I think the problem is that 'Model' is not recognized correctly as the first parameter of 'BindTo'. Visual studio tell me that "'MenuItemsCategory' is not a member of ' System.Web.Mvc.ViewUserControl(Of MvcApplication3.MvcApplication3.Models.MenuViewItems)'". But my class MenuViewItems does have this property. Also the namespace MvcApplication3.MvcApplication3.Models contains a class called 'Category'. So I think everything should be there, but the right overload of Bindto just isn't recognized.
What am I missing?
The example given on the website tells me to use
<%= Html.Telerik().Menu()
.Name("Menu")
.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;
}));
})
My code in Index.vbhtml is :
@imports Telerik.Web.Mvc.UI
@ModelType System.Web.Mvc.ViewUserControl(Of MvcApplication3.MvcApplication3.Models.MenuViewItems)
@Html.Telerik().Menu().Name("MainMenu").BindTo(Model.MenuItemsCategory, Sub(mapping) mapping.[For](Of [Category])(Sub(binding) binding.ItemDataBound(Sub(item As Telerik.Web.Mvc.UI.MenuItem, o As Category) item.Visible = True)))
I think the problem is that 'Model' is not recognized correctly as the first parameter of 'BindTo'. Visual studio tell me that "'MenuItemsCategory' is not a member of ' System.Web.Mvc.ViewUserControl(Of MvcApplication3.MvcApplication3.Models.MenuViewItems)'". But my class MenuViewItems does have this property. Also the namespace MvcApplication3.MvcApplication3.Models contains a class called 'Category'. So I think everything should be there, but the right overload of Bindto just isn't recognized.
What am I missing?