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

error when adding events

1 Answer 430 Views
MultiSelect
This is a migrated thread and some comments may be shown as answers.
Christian Sandöy
Top achievements
Rank 2
Christian Sandöy asked on 31 Jul 2017, 07:34 AM

When I try to  add event to a multiselect I get this 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

 I have tried these to method to add event

@(Html.Kendo().MultiSelectFor(m => m.OmviserNavne)
                                    .Placeholder("Vælg omviser...")
                                    .BindTo(ViewBag.Omviser)
                                    .Events(e =>
                                    {
                                        e.Change("onOmviserChange")
                                    })
                                    .Deferred())

@(Html.Kendo().MultiSelectFor(m => m.OmviserNavne)
                                    .Placeholder("Vælg omviser...")
                                    .BindTo(ViewBag.Omviser)
                                    .Events(events => events.Change("onOmviserChange"))
                                    .Deferred())

1 Answer, 1 is accepted

Sort by
0
Accepted
Dimitar
Telerik team
answered on 02 Aug 2017, 01:34 PM
Hello Christian,

I am attaching an ASP.NET Core solution where a similar scenario to the one described is demonstrated (Kendo UI MultiSelect with server binding).

In order to fix the error, you can cast the ViewBag variable to an explicit type:
.BindTo((YourDataType)ViewBag.Collection)

Another alternative would be to simply move the .Events(...) definition before BindTo(...). Both of the suggested approaches should be able to solve the issue.

Regards,
Dimitar
Progress Telerik
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Tags
MultiSelect
Asked by
Christian Sandöy
Top achievements
Rank 2
Answers by
Dimitar
Telerik team
Share this question
or