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

[Solved] The Type or Namespace 'Category' could not be found...

2 Answers 34 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.
Peter
Top achievements
Rank 1
Peter asked on 25 Feb 2011, 09:51 PM
I have been trying to implement the databound example of the Telerik menu control for the past 3 days with relatively no success. I have been able to get just the first level of the menu working, but when I try to link children, I get the error message, "The Type or Namespace 'Category' could not be found..."
The only way I have been able to get the first level to work, however, was to fully qualify my namespace when defining the IEnumerable<T> command and the first mappings.For<T> command.
In the code that I got from the Telerik menu example, there is no need to fully quaify classes inside the IEnumerable<T> command or the mappings.For<T> commands, yet if I do not I get compiler errors.

 

 

 

 

 

@model IEnumerable<SAP_Template.Models.Category>

 

@(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;

 

            })

 

        );

 

    })

 

)

 

I am coming to you folks as a last resort in the hope that someone may have come across this same problem in the past.  I am not looking to do anything fancy right now.  All I want to do is make a working example that has a bound menu to the Northwind database. Basically, I just want to extract the Telerik databound menu into a separate, MVC 3 C# (Razor) project.  I am sure the problem has something to do with my namespaces, but I have been spinning my wheels for the past 2 days, getting no where...

I have attached a zip file of my C# project. Any help would be greatly appreciated...

Regards,
Peter B

2 Answers, 1 is accepted

Sort by
0
Accepted
Atanas Korchev
Telerik team
answered on 28 Feb 2011, 08:37 AM
Hi Peter,

You can check this help article.

Regards,
Atanas Korchev
the Telerik team
Registration for Q1 2011 What’s New Webinar Week is now open. Mark your calendar for the week starting March 21st and book your seat for a walk through all the exciting stuff we ship with the new release!
0
Peter
Top achievements
Rank 1
answered on 28 Feb 2011, 01:51 PM
Atanas,
Thank you so much for the quick response.  Adding the assembly reference to my web.config file solved the problem!

 

 

 

 

<add assembly="System.Data.Linq, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/>

For some reason, when you create a new Telrik, MVC 3 application, this reference does NOT get automatically included for you.

Thanks again...

 

 

Tags
Menu
Asked by
Peter
Top achievements
Rank 1
Answers by
Atanas Korchev
Telerik team
Peter
Top achievements
Rank 1
Share this question
or