0

I cannot understand why do i have an error on my constructor line. I try to create a class that containes a WebGrid and a Custom set of filters here is the code

    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);
        }

    }

and on this line Grid = new System.Web.Helpers.WebGrid(source: m_GridData); I get an error:

The best overloaded method match for 'System.Web.Helpers.WebGrid.WebGrid(System.Collections.Generic.IEnumerable, System.Collections.Generic.IEnumerable, string, int, bool, bool, string, string, string, string, string, string, string)' has some invalid arguments

I am passing an IEnumerable to the constructor of the WebGrid so why do I get this error? al other properties have default values...

Any help would be appreciated..

EDIT 1: So after more digging found this specific error:

cannot convert from 'System.Collections.Generic.IEnumerable' to 'System.Collections.Generic.IEnumerable

that i got after passing all parameters:

 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);

and the error is for line source: m_GridData

now why is it that IEnumerable<T> cannot be converted to IEnumerable<dynamic>

Mortalus
  • 10,574
  • 11
  • 67
  • 117

1 Answers1

0

The WebGrid will require IEnumerable for the model

@model IEnumerable<.....>
haldo
  • 14,512
  • 5
  • 46
  • 52
Scott Gerold
  • 162
  • 1
  • 4