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

[Solved] Problem adding children in Visual Studio 2010

3 Answers 123 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Ken Lewis
Top achievements
Rank 1
Ken Lewis asked on 27 Apr 2010, 09:13 PM
I'm in the process of moving a project from Visual Studio 2008 to 2010. My TreeView with children worked fine there but I can't get it to work in 2010. I even added the code from the online "bind to model" demo, but I have the same issue. The problem seems to start as soon as I try to add the ".Children" code.

<%= Html.Telerik().TreeView() 
        .Name("TreeView"
        .BindTo(Model, mappings => 
        { 
            mappings.For<TelerikMvc.Models.Category>(binding => binding 
                    .ItemDataBound((item, category) => 
                    { 
                        item.Text = category.CategoryName; 
                    }) 
                    ); 
                    // Above works fine 
                    //.Children(category => category.Products)); 
 
            //mappings.For<TelerikMvc.Models.Product>(binding => binding 
            //        .ItemDataBound((item, product) => 
            //        { 
            //            item.Text = product.ProductName; 
            //        })); 
        }) 
%> 
 

One detail I notice when hovering over the "mappings" variable.
Without children, I see: "(parameter) NavigationBindingFactory<TreeViewItem> mappings"

As soon as I add the .Children part: "(parameter) TreeViewItem mappings"

Any idea what could be causing this? What am I missing?

Thanks,

Ken

3 Answers, 1 is accepted

Sort by
0
Atanas Korchev
Telerik team
answered on 28 Apr 2010, 07:35 AM
Hi Ken Lewis,

What is the exact problem? Could you paste the exception stacktrace (if any)?

Check if the following line is present in your web.config:

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

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

Without it the asp.net compiler will not know that the Linq 2 Sql objects implement IEnumerable<T> and binding the treeview will fail.

Greetings,
Atanas Korchev
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Ken Lewis
Top achievements
Rank 1
answered on 28 Apr 2010, 03:57 PM
Adding the assembly (either one works) fixed it!

Thank you, thank you, thank you!

Ken

0
it
Top achievements
Rank 1
answered on 13 Jun 2010, 08:08 AM
Dear Sir,

How can I use these code in vb.net.

Regards

Zin
Tags
TreeView
Asked by
Ken Lewis
Top achievements
Rank 1
Answers by
Atanas Korchev
Telerik team
Ken Lewis
Top achievements
Rank 1
it
Top achievements
Rank 1
Share this question
or