Bind jQuery Grid to SQL Data using ASP.NET MVC4

I am blogging this following

You can follow everything except the step 11 code you need to add the shared layout on top.


    ViewBag.Title = “Index”;

    Layout = “~/Views/Shared/_Layout.cshtml”;



<script type=”text/javascript”>   

    $(document).ready(function () {       

        // prepare the data       

        var source = {

            datatype: “json”,

            datafields: [{ name: ‘CompanyName’ }, { name: ‘ContactName’ },

        { name: ‘ContactTitle’ }, { name: ‘Address’ }, { name: ‘City’ }, ],

            url: ‘Customers/GetCustomers’



            source: source, theme: ‘classic’, columns: [{

                text: ‘Company Name’, datafield: ‘CompanyName’,

            width: 250 }, { text: ‘ContactName’, datafield: ‘ContactName’, width: 150 },

        { text: ‘Contact Title’, datafield: ‘ContactTitle’, width: 180 },

        { text: ‘Address’, datafield: ‘Address’, width: 200 },

        { text: ‘City’, datafield: ‘City’, width: 120 }]






<div id=”jqxgrid”></div>

You also have to watch the JQuery verion that you use in _Layout.cshtml.

<!DOCTYPE html>



    <meta charset=”utf-8″ />


    <link href=”@Url.Content(“~/Content/Site.css”)

rel=”stylesheet” type=”text/css” />

    <link href=”@Url.Content(“~/Content/jqx.base.css”)

rel=”stylesheet” type=”text/css” />

    <link href=”@Url.Content(“~/Content/jqx.classic.css”)

rel=”stylesheet” type=”text/css” />

    <script src=”@Url.Content(“~/Scripts/jquery-1.8.2.min.js”)


    <script src=”@Url.Content(“~/Scripts/jqxcore.js”)


    <script src=”@Url.Content(“~/Scripts/jqxbuttons.js”)


    <script src=”@Url.Content(“~/Scripts/jqxdata.js”)


    <script src=”@Url.Content(“~/Scripts/jqxgrid.js”)


    <script src=”@Url.Content(“~/Scripts/jqxgrid.selection.js”)


    <script src=”@Url.Content(“~/Scripts/jqxmenu.js”)


    <script src=”@Url.Content(“~/Scripts/jqxscrollbar.js”)




Bear in mind that the Scripts, Content and Shared folder is not created for the Empty Application in MVC 4.

Download the complete code from The sample file name is MvcAppJQueryGrid.rar. My MSN ID is


About chanmingman

Since March 2011 Microsoft Live Spaces migrated to Wordpress ( till now, I have is over 1 million viewers. This blog is about more than 50% telling you how to resolve error messages, especial for Microsoft products. The blog also has a lot of guidance teaching you how to get stated certain Microsoft technologies. The blog also uses as a help to keep my memory. The blog is never meant to give people consulting services or silver bullet solutions. It is a contribution to the community. Thanks for your support over the years. Ming Man is Microsoft MVP since year 2006. He is a software development manager for a multinational company. With 25 years of experience in the IT field, he has developed system using Clipper, COBOL, VB5, VB6, VB.NET, Java and C #. He has been using Visual Studio (.NET) since the Beta back in year 2000. He and the team have developed many projects using .NET platform such as SCM, and HR based applications. He is familiar with the N-Tier design of business application and is also an expert with database experience in MS SQL, Oracle and AS 400.
This entry was posted in .Net and tagged , . Bookmark the permalink.

One Response to Bind jQuery Grid to SQL Data using ASP.NET MVC4

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s