我正在尝试为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;因为它不是委托类型
答案 0 :(得分:0)
.Columns(columns =>
{
columns.Bound(c => c).Title("Text");
})