I was trying to implement Listview control of Kendo UI for MVC. I am trying to bind the list view with my model but I am getting this error :

"CS1977: 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 checked some other questions on stackoverflow with the same error but I am unable to know the cause for this error as this is kendo Syntax and there is nothing wrong with my code as far as I know.

The error is in this line::.DataSource(ds => ds

View Page:

@{
    ViewBag.Title = "Courses";
}
@using Kendo.Mvc.UI

<h2>Courses</h2>

<a href="/Home/Registration">Back</a>

<div class="bodywrap">
    <div class="CommonClass">

        @( Html.Kendo().ListView<K_SampleProject.Models.CourseModel>(Model)
          .Name("listView")
          .TagName("div")
          .ClientTemplateId("template")
          .DataSource(ds => ds
          .Model(model =>
          {
              //The unique identifier (primary key) of the model is the ProductID property
              model.Id(p => p.ProductID);

              // Declare a model field and optionally specify its default value (used when a new model instance is created)
              model.Field(p => p.ProductName).DefaultValue("N/A");

              // Declare a model field and make it readonly
              model.Field(p => p.UnitPrice).Editable(false);
          })
)
    .Pageable()
         )
    </div>
</div>


<script type="text/x-kendo-tmpl" id="template">
    <div class="product">
        <img src="@Url.Content("~/content/web/foods/")${ProductID}.jpg" alt="${ProductName} image" />
        <h3>${ProductName}</h3>
        <dl>
            <dt>Price:</dt>
            <dd>${kendo.toString(UnitPrice, "c")}</dd>
        </dl>
    </div>
</script>

Model
namespace K_SampleProject.Models
{
    public class CourseModel
    {
        public List<tbl_Courses> CourseList { get; set; }
        public string ProductID { get; set; }
        public string ProductName { get; set; }
        public string UnitPrice { get; set; }
    }
}

Controller
  public ActionResult Courses()
        {
            CourseModel Model = new CourseModel();
            RegistrationService ObjService = new RegistrationService();
            Model.CourseList = ObjService.GetCourses();
            return View(Model);
        }

Related posts

Recent Viewed