【问题标题】:WebGrid constructor parameters are wrongWebGrid构造函数参数错误
【发布时间】: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&lt;T&gt;不能转换成IEnumerable&lt;dynamic&gt;

【问题讨论】:

    标签: asp.net-mvc webgrid


    【解决方案1】:

    WebGrid 将需要 IEnumerable 用于模型

    @model IEnumerable<.....>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2012-03-25
      • 1970-01-01
      • 2021-10-24
      • 1970-01-01
      • 2012-04-18
      • 1970-01-01
      相关资源
      最近更新 更多