error when adding events

2 posts, 1 answers
  1. Christian Sandöy
    Christian Sandöy avatar
    17 posts
    Member since:
    Aug 2005

    Posted 31 Jul Link to this post

    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())

  2. Answer
    Dimitar
    Admin
    Dimitar avatar
    176 posts

    Posted 02 Aug Link to this post

    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.
Back to Top