We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback


Thread ID:





144947 May 29,2019 05:39 PM UTC May 30,2019 10:58 AM UTC ASP.NET Core - EJ 2 1
Tags: DataGrid
Erin Biundo
Asked On May 29, 2019 05:39 PM UTC


I'm using VS 2017 MVC .net Core Entity Framework Core.  The data is not binding.  I suspect maybe I need to reference something else in the DataSource.

I've Design First reverse engineered my models and add controller to create the scaffolding (CRUD) pages.

Now I have a table that is looping and building a grid, and I'm replacing it with Syncfusion GRID.

This is my Controler:
        public TblContractzsController(ContractsContext context)
            _context = context;

        // GET: TblContractzs
        public async Task<IActionResult> Index()
            return View(await _context.TblContractz.ToListAsync());
            //ViewBag.datasource = _context.TblContractz.ToList();
            //return View();

This is my View:
    <ejs-grid id="Grid" Datasource="ViewBag.datasource" allowPaging="true">

            <e-grid-column field="ContractName" headerText="Contract Name" textAlign="Right" width="120"></e-grid-column>



Thavasianand Sankaranarayanan [Syncfusion]
Replied On May 30, 2019 10:58 AM UTC

Hi Erin,  

Thanks for contacting Syncfusion support  

Query: “The data is not binding.  I suspect maybe I need to reference something else in the DataSource. 
From your query, we understand that you are facing issue while binding dataSource to Grid using entity framework. In your code example you have returned the dataSource instead of binding it to ViewBag. This may the  cause of the issue. Kindly assign the dataSource to Viewbag and define the dataSource to Grid. Refer the below modified code example 

<ejs-grid id="Grid" Datasource="ViewBag.datasource" allowPaging="true"> 
        <e-grid-column field="OrderID" headerText="Contract Name" textAlign="Right" width="120"></e-grid-column> 


public async Task<IActionResult> Index() 
           // await _context.Orders.ToList(); 
           // return View(); 
            ViewBag.datasource = _context.Orders.Take(100).ToList(); 
            return View(); 

Refer the below screenshot for the output 


For your convenience we have prepared a sample which can be downloaded from below link  

Please get back to us if you have further queries.   

Thavasianand S.  


This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon