c#HtmlHelper无法转换lambda表达式

时间:2016-03-03 13:07:22

标签: c# asp.net-mvc lambda

我正在尝试为kendogrid创建一个自定义HtmlHelper以用于参数。
我的问题是如何重构我的viewmodel接受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")));

        }
    }
}`

和我的viewmodel类

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

问题:c =&gt; c.Text
MSVS:无法将lambda表达式转换为&#39; string&#39;因为它不是委托类型

1 个答案:

答案 0 :(得分:0)

 .Columns(columns =>
  {
    columns.Bound(c => c).Title("Text");
  })
相关问题