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

[Solved] Ye old "Cannot convert lambda expression to type 'string' because it is not a delegate type"

1 Answer 85 Views
Grid
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Michael
Top achievements
Rank 1
Michael asked on 27 Apr 2012, 10:13 PM

I'm getting the following error:

System.Web.HttpCompileException
c:\inetpub\sites\...\Areas\Admin\Views\Administrator\ListWorkflows.cshtml(34): error CS1660: Cannot convert lambda expression to type 'string' because it is not a delegate type.

If I removed line 34 marked **** below it works but when it is not comment out it throws the error. 

@(Html.Telerik().Grid<... .Areas.Admin.ViewModels.Administrator.ListWorkflowViewModel>()
    .Name("Grid")
    .DataKeys(keys => { 
        keys.Add(m => m.Id);
    })
    .Columns(columns => {
        columns.Bound(m => m.ConsolidationId).Title("Consolidation Id");
        columns.Bound(m => m.CurrentStatus).Title("Status");
        columns.Bound(m => m.CurrentStatusDate).Title("Status Date");
****        columns.Bound(m => m.CurrentStatusedByEmail).Title("Statused By Email");
        columns.Bound(m => m.CreatedDate).Title("Created Date");
        columns.Bound(m => m.Email)
            .ClientTemplate("<a href='" + Url.Action("Impersonate", "Impersonate") + "?email=<#= Email #>'><#= Email #></a>")
            .Title("Patient Email");
        columns.Bound(m => m.Id)
            .ClientTemplate("<a href='#' workflowId='<#= Id #>' class='changeStatus'>Change Status</a>")
            .Title("Change Status");
    })
    .Pageable(paging => 
            paging.PageSize(50)
                  .Style(GridPagerStyles.NextPreviousAndNumeric)
                  .Position(GridPagerPosition.Bottom)
                  .PageTo(1)
    )
    .Selectable()
    .Sortable(sorting => sorting.Enabled(true))
    .Filterable()
    .DataBinding(dataBinding => {
        dataBinding.Ajax().Select("_SelectWorkflows", "Administrator", new { name = Model.Name});
    })
    .ClientEvents(events => events
        .OnDataBound("onDataBound")
    )
)

The view model it is being bound to looks like this:

    public class WorkflowListItem {
        public string ConsolidationId { get; set; }
        public DateTime CreatedDate { get; set; }
        public string CurrentStatus { get; set; }
        public DateTime CurrentStatusDate { get; set; }
        public string CurrentStatusedByEmail { get; set; }
        public string Email { get; set; }
        public string Id { get; set; }
        public string SiteName { get; set; }
        public string Type { get; set; }
    }

I see no difference that should be causing this error??

Any help is appreciated!!

Found the solution. I hadn't added CurrentStatusedByEmail to the paging ViewModel.

1 Answer, 1 is accepted

Sort by
0
Umer
Top achievements
Rank 1
answered on 30 Apr 2012, 06:47 AM
hi michael...


try this



Html.Telerik().Grid((IEnumerable<.Areas.Admin.ViewModels.Administrator.ListWorkflowViewModel>)ViewData["yourChacheDataHere"]




or


Html.Telerik().Grid(IEnumerable<.Areas.Admin.ViewModels.Administrator.ListWorkflowViewModel>)
Tags
Grid
Asked by
Michael
Top achievements
Rank 1
Answers by
Umer
Top achievements
Rank 1
Share this question
or