WebGrid构造函数参数错误

问题描述 投票:0回答:1

我不明白为什么我的构造函数行会出错。我尝试创建一个包含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>

asp.net-mvc webgrid
1个回答
0
投票

WebGrid将需要模型的IEnumerable

@model IEnumerable<.....>
© www.soinside.com 2019 - 2024. All rights reserved.