Introduction
In this post, we will see how to bind data in a grid by using the ReactJS library, ASP.Net Web API 2, and Entity Framework ORM.
In this demo, we are going create a sample application, then generate a mapping of our employee table by using Entity Framework, after that, we will create a service which returns all data from employee table. Finally, ReactJS as a library will be used in order to bind data in a grid.
Let’s start.
SQL Database part
Here, you will find the scripts to create a database and table.
Create Database
- USE [master]
- GO
- /****** Object: Database [DbEmployee] Script Date: 3/26/2017 6:19:33 AM ******/
- CREATE DATABASE [DbEmployee]
- CONTAINMENT = NONE
- ON PRIMARY
- ( NAME = N'DbEmployee', FILENAME = N'c:\Program Files (x86)\Microsoft SQL Server\MSSQL11.MSSQLSERVER\MSSQL\DATA\DbEmployee.mdf' , SIZE = 3072KB , MAXSIZE = UNLIMITED, FILEGROWTH = 1024KB )
- LOG ON
- ( NAME = N'DbEmployee_log', FILENAME = N'c:\Program Files (x86)\Microsoft SQL Server\MSSQL11.MSSQLSERVER\MSSQL\DATA\DbEmployee_log.ldf' , SIZE = 1024KB , MAXSIZE = 2048GB , FILEGROWTH = 10%)
- GO
- ALTER DATABASE [DbEmployee] SET COMPATIBILITY_LEVEL = 110
- GO
- IF (1 = FULLTEXTSERVICEPROPERTY('IsFullTextInstalled'))
- begin
- EXEC [DbEmployee].[dbo].[sp_fulltext_database] @action = 'enable'
- end
- GO
- ALTER DATABASE [DbEmployee] SET ANSI_NULL_DEFAULT OFF
- GO
- ALTER DATABASE [DbEmployee] SET ANSI_NULLS OFF
- GO
- ALTER DATABASE [DbEmployee] SET ANSI_PADDING OFF
- GO
- ALTER DATABASE [DbEmployee] SET ANSI_WARNINGS OFF
- GO
- ALTER DATABASE [DbEmployee] SET ARITHABORT OFF
- GO
- ALTER DATABASE [DbEmployee] SET AUTO_CLOSE OFF
- GO
- ALTER DATABASE [DbEmployee] SET AUTO_CREATE_STATISTICS ON
- GO
- ALTER DATABASE [DbEmployee] SET AUTO_SHRINK OFF
- GO
- ALTER DATABASE [DbEmployee] SET AUTO_UPDATE_STATISTICS ON
- GO
- ALTER DATABASE [DbEmployee] SET CURSOR_CLOSE_ON_COMMIT OFF
- GO
- ALTER DATABASE [DbEmployee] SET CURSOR_DEFAULT GLOBAL
- GO
- ALTER DATABASE [DbEmployee] SET CONCAT_NULL_YIELDS_NULL OFF
- GO
- ALTER DATABASE [DbEmployee] SET NUMERIC_ROUNDABORT OFF
- GO
- ALTER DATABASE [DbEmployee] SET QUOTED_IDENTIFIER OFF
- GO
- ALTER DATABASE [DbEmployee] SET RECURSIVE_TRIGGERS OFF
- GO
- ALTER DATABASE [DbEmployee] SET DISABLE_BROKER
- GO
- ALTER DATABASE [DbEmployee] SET AUTO_UPDATE_STATISTICS_ASYNC OFF
- GO
- ALTER DATABASE [DbEmployee] SET DATE_CORRELATION_OPTIMIZATION OFF
- GO
- ALTER DATABASE [DbEmployee] SET TRUSTWORTHY OFF
- GO
- ALTER DATABASE [DbEmployee] SET ALLOW_SNAPSHOT_ISOLATION OFF
- GO
- ALTER DATABASE [DbEmployee] SET PARAMETERIZATION SIMPLE
- GO
- ALTER DATABASE [DbEmployee] SET READ_COMMITTED_SNAPSHOT OFF
- GO
- ALTER DATABASE [DbEmployee] SET HONOR_BROKER_PRIORITY OFF
- GO
- ALTER DATABASE [DbEmployee] SET RECOVERY SIMPLE
- GO
- ALTER DATABASE [DbEmployee] SET MULTI_USER
- GO
- ALTER DATABASE [DbEmployee] SET PAGE_VERIFY CHECKSUM
- GO
- ALTER DATABASE [DbEmployee] SET DB_CHAINING OFF
- GO
- ALTER DATABASE [DbEmployee] SET FILESTREAM( NON_TRANSACTED_ACCESS = OFF )
- GO
- ALTER DATABASE [DbEmployee] SET TARGET_RECOVERY_TIME = 0 SECONDS
- GO
- ALTER DATABASE [DbEmployee] SET READ_WRITE
- GO
Create Table
- USE [DbEmployee]
- GO
- /****** Object: Table [dbo].[EmployeeTable] Script Date: 3/26/2017 6:20:03 AM ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- SET ANSI_PADDING ON
- GO
- CREATE TABLE [dbo].[EmployeeTable](
- [EmployeeID] [int] IDENTITY(1,1) NOT NULL,
- [FirstName] [varchar](50) NULL,
- [LastName] [varchar](50) NULL,
- [Gender] [varchar](50) NULL,
- [Designation] [nchar](10) NULL,
- [Salary] [int] NULL,
- [City] [varchar](50) NULL,
- [Country] [varchar](50) NULL,
- CONSTRAINT [PK_EmployeeTable] PRIMARY KEY CLUSTERED
- (
- [EmployeeID] ASC
- )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
- ) ON [PRIMARY]
- GO
- SET ANSI_PADDING OFF
- GO














Guest UserPosted Feb 10, 2019, 10:12 PM
Thanks for the article. I couldn't get this to work. However, I'm troubleshooting the JSX.
Les PinterPosted Jul 22, 2018, 5:05 PM
I really appreciate your article. First time I've displayed a table of SQL data using React. I have a question, though, and perhaps you can point me in the right direction. I want to pass a parameter - in my case the first letter of the last name - to the query, preferably based on a dropdown listbox in the html page. I've already noted that if I change the ReactDOM.Render url to end in "?letter=A" the modified query works. What modifications would I need to make to do that interactively? Thanks in advance for your suggestions.
SUJIL KUMARPosted Apr 18, 2018, 2:27 AM
Great Article , Please can you share the Code with Complete CRUD operation with Same Sample ?
kzelda linkPosted Apr 16, 2017, 4:47 AM
Good Article , thx