Hi,
I am a beginner and just starting out (not professional, just trying to learn) please help me out;
when I run the code, the browser does not show any data, just an empty grid.
I think there is something I don't understand in the exchange of data between the controller
class and the cshtml view.
The result looks like this:

My controller class has the following code: // GET: Employees
public async Task<IActionResult> Index()
{
ViewBag.DataSource = await _context.Employees.ToListAsync();
return View(ViewBag.DataSource);
}
Note: the original code only has this line "return View(await _context.Employees.ToListAsync());"
My view Index.cshtml has the following code:
@model IEnumerable<Sample.Models.Employee>
@{
ViewData["Title"] = "Index";
}
<h2>Index</h2>
<p>
<a asp-action="Create">Create New</a>
</p>
<ejs-grid id="Grid" [email protected]> <e-grid-columns> <e-grid-column field="Code" headerText="Code" textAlign="Left" width="70"></e-grid-column>
<e-grid-column field="DateHired" headerText="Date Hired"
textAlign="Right" width="70"
format="{0:MM/dd/yyyy}"></e-grid-column> <e-grid-column field="LastName" headerText="Last Name" width="120"></e-grid-column> <e-grid-column field="FirstName" headerText="First Name" width="120"></e-grid-column> </e-grid-columns> </ejs-grid>
Just in case the following information is required:
My model class has the following code: public class Person
{
public int ID { get; set; }
[Required]
[StringLength(50)]
[Display(Name = "Last Name")]
public string LastName { get; set; }
[Required]
[StringLength(100)]
[Display(Name = "First Name")]
public string FirstName { get; set; }
}
public class Employee : Person
{
[Required]
[StringLength(20)]
[Display(Name = "Code")]
public string Code { get; set; }
[Required]
[DataType(DataType.Date)]
[Display(Name = "Date Hired")]
public DateTime DateHired { get; set; }
}
Development tools and Dependencies I used:
1. Visual Studio Community 2017 v15.7.3
2. Microsoft.AspNetCore.App v2.1.0
3. Microsoft.NetCore.App v2.1.0
4. Microsoft.VisualStudio.Web.CodeGeneration.Design v2.1.0
5. Syncfusion.EJ2 v16.1.0.37
(thru NuGet Package Manager)