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

Design time error in cshtml: Cannot convert lambda expression to type 'string' because it is not a delegate type

3 Answers 741 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Kevin
Top achievements
Rank 1
Kevin asked on 08 Aug 2012, 09:00 PM
I am getting no intellisense and design time errors when using the Bound method to declare columns.  When I run the site it works fine, but isn't the whole point of using the lambda instead of magic strings so I can get accurate design time errors?

In the following code, I get design time errors for each of the lambdas in the columns.Bound declarations.  Am I doing something wrong?

@(Html.Kendo().Grid<KBMaxLive.Domain.KBUser>()
    .Name("grid")
    .Columns(columns => {
        columns.Bound(u => u.Email).ClientTemplate("<a>#: Email #</a>");
        columns.Bound(u => u.IDUserRole);
        columns.Bound(u => u.FirstName);
        columns.Bound(u => u.LastName);
        columns.Bound(u => u.IsOnLine);
    })
    .Pageable(paging => paging.Enabled(true).PageSizes(new int[]{5, 10, 20, 50}))
    .Sortable()
    .Filterable()
    .Groupable()
    .Selectable(select => select.Type(GridSelectionType.Row).Mode(GridSelectionMode.Multiple))
    .DataSource(dataSource => dataSource
        .Ajax()
        .Read(read => read.Action("Users_Read""Users"))
        .PageSize(20))
    
  )  

3 Answers, 1 is accepted

Sort by
0
Dimo
Telerik team
answered on 13 Aug 2012, 10:50 AM
Hello Kevin,

The provided code snippet works correctly on my side. Feel free to send a standalone project for inspection after checking whether there is some problem not related to the Grid.

Regards,
Dimo
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Ravi
Top achievements
Rank 1
answered on 16 Oct 2012, 12:32 PM
Hello,

I am also facing the similar error please suggest me. find my code below

@{Html.Kendo().Grid(Model)

        .Name("GridSam")
        .DataSource(dataSource => dataSource
            .Server()
                     .PageSize(20)
            .Model(model => model.Id(p => p.ProductID))
                )

        .Columns(c =>
        {
            c.AutoGenerate(column =>
            {
                //customize autogenereted column's settings                                                   
                column.Width = "150px";
                column.Bound(p => p.ProductID).Groupable(false);
                column.Bound(p => p.ProductID);

            });
        })

          .Resizable(resizing => resizing.Columns(true))
          .Scrollable(scrolling => scrolling.Enabled(true).Height(600))
          .Sortable(sorting => sorting.Enabled(true))
          .Groupable(grouping => grouping.Enabled(true))
          .Filterable(filtering => filtering.Enabled(true))
          .Reorderable(reorder => reorder.Columns(true))
          .Pageable(Pageable => Pageable.Enabled(true).PreviousNext(true).Input(true).PageSizes(true))
          .Selectable(selectable => selectable.Mode(GridSelectionMode.Single))
          .Render();
                }

Regards,
Ravi

 

 

 

0
Keith
Top achievements
Rank 1
Iron
answered on 23 Mar 2022, 03:45 PM

Fast forward 10 years, and I'm seeing this same problem with Visual Studio 2019 and an ASP.NET MVC5 project.

Telerik folks: How about some guidance or suggestions here?

Anton Mironov
Telerik team
commented on 28 Mar 2022, 09:46 AM

Hi Keith,

Thank you for contacting the team. 

As my colleague pointed out in the last reply, the issue is probably caused by additional logic added.

The fastest route to getting you up and running is if you could provide a runnable, isolated, sample project. Examining this project will let us replicate the issue locally and further troubleshoot it.

Attached is a sample project that implements a Kendo UI Grid that is working out of the box. Feel free to use it as a template.

Looking forward to hearing back from you.


Kind Regards,
Anton Mironov

Tags
Grid
Asked by
Kevin
Top achievements
Rank 1
Answers by
Dimo
Telerik team
Ravi
Top achievements
Rank 1
Keith
Top achievements
Rank 1
Iron
Share this question
or