c# HtmlHelper 无法转换 lambda 表达式

本文关键字:lambda 表达式 转换 HtmlHelper | 更新日期: 2023-09-27 18:37:08

我正在尝试为kendogrid创建一个自定义的HtmlHelper以与参数一起使用。
我的问题是如何重新定义我的视图模型以接受 htmlhelper 的接口?
这是我的 htmlhelper 类

using System;
using System.Web.Mvc;
using Kendo.Mvc.UI;
using System.Linq;
using Popup.BLL.ViewModel;
namespace Popup.Web.KendoHelper
{
    public static class PickListHelper
    {
        public static Kendo.Mvc.UI.Fluent.GridBuilder<T> PickList<T>(this HtmlHelper helper, string gridName, string gridClass, int gridHeight)
             where T : class
        {
            return helper.Kendo().Grid<T>()
            .Name(gridName)
                    .Columns(columns =>
                    {
                        columns.Bound(c => c.Text).Title("Associated");
                    })
            .HtmlAttributes(new { @class = gridClass, style = "height: " + gridHeight + "px;" })
            .Scrollable()
            .Sortable()
            .Selectable(selectable => selectable
                .Mode(GridSelectionMode.Multiple))
            .Events(events => events.Change("onSelectAssociatedGridElements"))
            .DataSource(datasource => datasource.Ajax().Read(read => read.Data("getAssociatedGridDataSource")));
        }
    }
}`

和我的视图模型类

public class TextViewModel
    {
       public int Id { get; set; }
       public string Text { get; set; }
    }

问题:c => c.文本
MSVS:无法将 lambda 表达式转换为类型"字符串",因为它不是委托类型

c# HtmlHelper 无法转换 lambda 表达式

 .Columns(columns =>
  {
    columns.Bound(c => c).Title("Text");
  })