This project is read-only.

Grid.Mvc not rendering properly

May 14, 2013 at 1:58 PM
Edited May 14, 2013 at 2:04 PM
I tried Grid.Mvc, But I am getting compilation error as follows

The type arguments for method 'GridMvc.Html.GridExtensions.Grid<T>(System.Web.Mvc.HtmlHelper, System.Collections.Generic.IEnumerable<T>)' cannot be inferred from the usage. Try specifying the type arguments explicitly.

Anybody please help...
Thanks in Advance.
May 14, 2013 at 2:31 PM
Hi,

Can you provide your code?
Jun 25, 2013 at 8:45 AM
I have the same problem.

Error message: CS0411: The type arguments for method 'GridMvc.Html.GridExtensions.Grid<T>(System.Web.Mvc.HtmlHelper, System.Collections.Generic.IEnumerable<T>)' cannot be inferred from the usage. Try specifying the type arguments explicitly.

Can't find a solution.

My code:
@using GridMvc.Html
@using GridMvc.Sorting
@model CustomerPortal.Models.F_RELATIE



@{
    ViewBag.Title = "Module relatie";
}

@if (Request.IsAuthenticated)
{
    <text>

        @Html.Grid(Model).AutoGenerateColumns()

    </text>
}
Jun 25, 2013 at 8:48 AM
Hi you need to pass IEnumerable<T> to @Html.Grid method - collection of elements, that you want to display. Is F_RELATIE derrives from IEnumerable?
Jun 25, 2013 at 8:55 AM
Thanks for the fast reply.
My controller returns IEnumerable<F_RELATIE> f_relatie to the view
        //
        // GET: /Relatie/

        public ActionResult Index()
        {
            IEnumerable<F_RELATIE> f_relatie = db.F_RELATIE.Include(f => f.Actie).Include(f => f.Module);
            return View(f_relatie);
        }
Jun 25, 2013 at 8:57 AM
Then you need to specify this in the view:
@model IEnumerable<CustomerPortal.Models.F_RELATIE>
Jun 25, 2013 at 8:59 AM
You're a hero!
That's the solution.
Thanks very much :)