Bind multiple grids

Jun 6, 2014 at 2:06 PM
Hi,
I have two grids in a View and a foreach loop in a table and I need to bind them from a single ViewModel.
I have created a Repository Model that returns the data in IEnumerable format for each of the grids and table.
Please guide me as to how bind data in the grids and table using IEnumerable.

Thanks,
Priya K
Coordinator
Jun 22, 2014 at 8:36 AM
Hi,

Create a ViewModel with 2 IEnumerable properties:
    public class MyViewModel
    {
        public IEnumerable<MyGridItem> Grid1Items { get; set; }
        public IEnumerable<MyGridItem> Grid12tems { get; set; }
    }
Then bind each grid to his collection in the view:
@model MyViewModel


@Html.Grid(Model.Grid1Items).Columns( .... )


@Html.Grid(Model.Grid2Items).Columns( .... )
See also https://gridmvc.codeplex.com/wikipage?title=Multipile%20grids%20on%20the%20page&referringTitle=Documentation