I have dynamic column and write dynamic style but I receive an error:
CS1977 C# Cannot use a lambda expression as an argument to a dynamically dispatched operation without first casting it to a delegate or expression tree type.
View:
WebGrid grid = new WebGrid(Model);
List<WebGridColumn> columnsL = new List<WebGridColumn>();
for (int i = 0; i < Model.First().Data.Count; i++)
{
int local = i;
columnsL.Add(grid.Column(Model.First().Data[i].Name, Model.First().Data[i].Label,format: item => new MvcHtmlString("<text>" + item.Data[local].Value +"</text>")
));
}
@grid.GetHtml(tableStyle: "table table-striped table-bordered", columns: columnsL)