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

[Solved] cannot use a lambda expression as an argument to a dynamically dispatched operation

2 Answers 150 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.
John
Top achievements
Rank 1
John asked on 13 Apr 2012, 05:07 PM
I'm new to Telerik and my company has purchased the MVC ASP.NET controls.  I'm trying to bind a List<Gadget> to the TreeView control.  Here is my view:

@{
                Html.Telerik().TreeView()
                    .Name("TreeView")
                    .DragAndDrop(settings => settings
                        .DropTargets(".drop-area")
                    )
                    .ClientEvents(events => events
                    .OnNodeDrop("onNodeDrop")
                    .OnNodeDragging("onNodeDragging")
                )
                .BindTo(Model, mappings => {
                })
                .Render();
            }

However, I'm receiving the following error:

"Cannot use a lambda expression as an argument to a dynamically dispatched operation without first casting it to a delegate or expression tree type"

The error is occuring on the following line:
.BindTo(Model, mappings => {

Am I doing something wrong?

2 Answers, 1 is accepted

Sort by
0
Alex Gyoshev
Telerik team
answered on 16 Apr 2012, 02:18 PM
Hello John,

It is most likely that the page Model is not of an IEnumerable type, or that System.Data.Linq is not included for the code of the View. See the "Compilation error when binding navigation component" section of the troubleshooting help topic.

Greetings,
Alex Gyoshev
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the Telerik Extensions for ASP.MET MVC, subscribe to their blog feed now.
0
John
Top achievements
Rank 1
answered on 19 Apr 2012, 08:01 PM
Adding the following line to the CSHTML file did the trick:

@model IEnumerable<IGadget>
Tags
TreeView
Asked by
John
Top achievements
Rank 1
Answers by
Alex Gyoshev
Telerik team
John
Top achievements
Rank 1
Share this question
or