Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
375
Error message when binding to data source using Linq
posted

Hi, I'm trying to get my grid to bind to a Linq to Entity Framework data source, but I'm getting an error in the Javascript (attached).

I'm using MVC, and have set up the data model to use remote filtering, paging, grouping and sorting. The controller is set up as follows. Please note that the method GetLinqPagingGridModel simply returns a suitable grid model with the DataSourceUrl set to the LinqInfragisticsGrid action method. The DataSource property for the GridModel doesn't get set.

public ActionResult LinqInfragistics()
{

    GridModel model = InfragisticsGridHelper.GetLinqPagingGridModel(GRID_ID, "ID", Url.Action("LinqInfragisticsGrid"));
    AddInfragisticsGridColumns(model);
    return View("Infragistics", model);
}

[GridDataSourceAction]
public ActionResult LinqInfragisticsGrid()
{
    // Returns the data model as an IQueryable object (required by the grid's data source).
    return View("Infragistics", GetMediaGridDataViaLinq());
}

private IQueryable<MediaBrowserViewModel> GetMediaGridDataViaLinq()
{
    var dataModel = new DataModel();
    IQueryable<MediaBrowserViewModel> model =
        dataModel.tblMedias.Where(
        m => m.IsSystem == "N" || (m.LogicalID >= 0xFFD8 && m.LogicalID <= 0xFFDF) || (m.LogicalID >= 0xFFD0 && m.LogicalID <= 0xFFD7))
        .Select(
            m => new MediaBrowserViewModel
            {
                ID = (long)m.ID,
               LogicalID = (long)m.LogicalID,
               Description = m.Description,
               Option1 = "1",
               Option2 = "2"
           });
    return model;
}

The grid rendering in the razor view is very simple, and looks like -

@(Html.Infragistics().Grid(Model))

Any thoughts on what I'm doing wrong? I'm not getting any errors when I get the data from a stored procedure.

Parents
No Data
Reply
  • 645
    Offline posted

    In internet explorer, press F12 to get the developer tools.  Now choose network and start capturing.

    Refresh the page in your browser.

    Now go back to the developer tools and look at the request list.  there will be one to your LinqInfragisticsGrid controller, probably with a status of 500

    Double click this and now choose the response body tab.

    There is likely to be an HTML error message telling you what really went wrong.

Children
No Data