【发布时间】:2014-07-06 15:31:19
【问题描述】:
我不明白为什么我的构造函数行有错误。 我尝试创建一个包含 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,字符串,int,bool, 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>
【问题讨论】:
标签: asp.net-mvc webgrid