我不明白为什么我的构造函数行会出错。我尝试创建一个包含WebGrid和自定义过滤器集的类这是代码
public class FilterableWebGrid<T> : System.Web.Helpers.WebGrid
{
public System.Web.Helpers.WebGrid Grid { get; set; }
public IEnumerable<AbstractSearch> Filters { get; set; }
private IEnumerable<T> m_GridData;
public FilterableWebGrid(T Model)
{
Grid = new System.Web.Helpers.WebGrid(source: m_GridData);
}
}
并且在此行Grid = new System.Web.Helpers.WebGrid(source: m_GridData);
我收到一个错误:
最佳重载方法匹配'System.Web.Helpers.WebGrid.WebGrid(System.Collections.Generic.IEnumerable,System.Collections.Generic.IEnumerable,字符串,整数,布尔值,bool,string,string,string,string,string,string,string)'有一些无效的参数
我正在将IEnumerable
传递给WebGrid的构造函数,所以为什么会出现此错误?其他属性均具有默认值...
任何帮助将不胜感激。
编辑1:因此,在进一步挖掘后发现了此特定错误:
无法从'System.Collections.Generic.IEnumerable'转换为'System.Collections.Generic.IEnumerable
我通过所有参数后得到:
Grid = new System.Web.Helpers.WebGrid(
source: m_GridData,
columnNames: null,
defaultSort: null,
rowsPerPage: 10,
canPage: true,
canSort: true,
ajaxUpdateContainerId: null,
ajaxUpdateCallback: null,
fieldNamePrefix: null,
pageFieldName: null,
selectionFieldName: null,
sortFieldName: null,
sortDirectionFieldName: null);
并且错误是针对行source: m_GridData
现在为什么IEnumerable<T>
无法转换为IEnumerable<dynamic>
WebGrid
将需要模型的IEnumerable
@model IEnumerable<.....>