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

[Solved] Problem with bindto

1 Answer 36 Views
Menu
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
A
Top achievements
Rank 1
A asked on 27 Jul 2011, 11:31 AM
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?

1 Answer, 1 is accepted

Sort by
0
A
Top achievements
Rank 1
answered on 01 Aug 2011, 03:16 PM
I solved the problem. A partial answer is to remove the following statement:
@ModelType System.Web.Mvc.ViewUserControl(Of MvcApplication3.MvcApplication3.Models.MenuViewItems)

I changed more things, but cannot remember what.
Tags
Menu
Asked by
A
Top achievements
Rank 1
Answers by
A
Top achievements
Rank 1
Share this question
or