This article gives a walk-through of selecting table rows with checkboxes using the JQuery plugin Tabulator.js with SQL Server as backend database and server as ASP.Net.
Below is the screenshot of the final output that we want to achieve at the end of this tutorial.

In the above result, we are displaying the data from the database; i.e SQL Server 2014 and fetching the data using jquery ajax call with WebMethod in the ASP.Net code behind CustomerDetails.aspx.cs.
The link for tabulator.js for more details is at http://tabulator.info/ and for the row selection documentation is at http://tabulator.info/docs/4.6/select.
Prerequisites for this tutorial
- Visual Studio (any version)
- SQL Server (any database version)
- Tabulator.js and Tabulator.css (download from the official site provided above)
Database structure and data
Create the database SQL server script with name as Practice.
- USE master;
- GO
- IF DB_ID (N'Practice') IS NOT NULL
- DROP DATABASE Practice;
- GO
- CREATE DATABASE Practice;
Now create the table called tblCustomers2
- USE [Practice]
- GO
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- CREATE TABLE [dbo].[tblCustomer2](
- [CustomerID] [float] NULL,
- [CustomerName] [nvarchar](255) NULL,
- [ContactName] [nvarchar](255) NULL,
- [Address] [nvarchar](255) NULL,
- [City] [nvarchar](255) NULL,
- [PostalCode] [float] NULL,
- [Country] [nvarchar](255) NULL
- ) ON [PRIMARY]
- GO
Steps to follow:
Step 1
Create a new project in Visual Studio as given in the below screenshot.
Step 2
Create Web Forms with No Authentication.

Step 3
Below is the structure of the project.

Step 4
Add the Tabulator.js and Tabulator.css into Scripts and Content/CSS folders.


Step 5
Now add the Tabulator.Js and Tabulator.css into Site.Master and Bundle.config as shown in the below screen.

Step 6
Now we have to change the page header and place the application in the header.
- <nav class="navbar navbar-expand-lg navbar-dark bg-primary">
- <a class="navbar-brand" href="#">Tabulator with C#</a>
- <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarColor01" aria-controls="navbarColor01" aria-expanded="false" aria-label="Toggle navigation">
- <span class="navbar-toggler-icon"></span>
- </button>
- <div class="collapse navbar-collapse" id="navbarColor01">
- <ul class="navbar-nav mr-auto">
- <li class="nav-item active">
- <a class="nav-link" href="/">Home <span class="sr-only">(current)</span></a>
- </li>
- <li class="nav-item">
- <a class="nav-link" href="CustomerDetails.aspx">Customer <span class="sr-only">(current)</span></a>
- </li>
- </ul>
- </div>
- </nav>
Step 7
Now create a class library as Database and in that create a class as CustomerDB.cs which will handle our database operation using normal ADO.Net SqlDataAdapter to read that from the database SQL query.

- public class CustomerDB
- {
- public readonly SqlConnection Conn = null;
- public CustomerDB()
- {
- this.Conn = new SqlConnection(ConfigurationManager.AppSettings["SQlConnectionString"].ToString());
- }
- /// <summary>
- /// This method will get the list of Customer from database table CustomerRawInfo.
- /// </summary>
- /// <returns>List of customers in datatable</returns>
- public DataTable Customers
- {
- get
- {
- string Query = string.Empty;
- DataTable dataTable = new DataTable();
- SqlDataAdapter sqlDataAdapter = null;
- try
- {
- Query = "SELECT CUSTOMERID,CUSTOMERNAME,CONTACTNAME,ADDRESS,CITY,POSTALCODE,COUNTRY FROM PRACTICE.DBO.TBLCUSTOMER2 WITH(NOLOCK)";
- SqlCommand sqlCommand = new SqlCommand(Query, Conn);
- Conn.Open();
- // create data adapter
- sqlDataAdapter = new SqlDataAdapter(sqlCommand);
- // this will query your database and return the result to your datatable
- sqlDataAdapter.Fill(dataTable);
- }
- catch (Exception ex)
- {
- dataTable = null;
- }
- finally
- {
- Conn.Close();
- sqlDataAdapter.Dispose();
- }
- return dataTable;
- }
- }
- }
In the connection string provide the details of your database inside the web.config file,
After this build the class library Database and then add the reference to TabulatorWithAspdotnet.

Step 8
Create a web form name CustomerDetails.aspx and in the code bind CustomerDetails.aspx.cs and fetch the data from SQL Database using the class library Database Repository class. To fill the page; i.e CustomerDetails.aspx with SQL database data, we are displaying it using the HTML Table for which table header will be filled with defined columns and rows will be filled from code behind (from CustomerDetails.aspx.cs) with HTML table body structure.
CustomerDetails.aspx.cs(code behind)

Join the conversation! Your thoughts help the community grow.