.NET dhtmlxConnector using MSSQL Store Procedures

I was wondering if you can send me a sample of how to populate a dhtmlxGrid using ASP .NET and MSSQL Store Procedures with parameters. We are currently using C#.

I’m able to initialize using a SQL query. However I want to be able to use Store Procedures.

gridBasicSQLConnector.ashx.cs:

using System;
using System.Collections.Generic;
using System.Linq;
using dhtmlxConnectors;
using System.Web;
using System.Configuration;

namespace MyTest
{
    /// <summary>
    /// Summary description for gridBasicSQLConnector
    /// </summary>
    
    public class gridBasicSQLConnector : dhtmlxRequestHandler
    {
        public override IdhtmlxConnector CreateConnector(HttpContext context)
        {
            dhtmlxGridConnector connector = new dhtmlxGridConnector(
                "SELECT ProductName, Description FROM Products",
                "ProductID",
                dhtmlxDatabaseAdapterType.SqlServer2005,
                ConfigurationManager.ConnectionStrings ["website_newConnectionString"].ConnectionString
            );

            return connector;
        }
    }
}

Client:

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="grid_basic.aspx.cs" Inherits="MyTest.grid_basic" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <link href="codebase/dhtmlxGrid/codebase/dhtmlxgrid.css" rel="stylesheet" type="text/css" />
    <script src="codebase/dhtmlxGrid/codebase/dhtmlxcommon.js" type="text/javascript"></script>
    <script src="codebase/dhtmlxGrid/codebase/dhtmlxgrid.js" type="text/javascript"></script>
    <script src="codebase/dhtmlxGrid/codebase/dhtmlxgridcell.js" type="text/javascript"></script>
    
    <link href="codebase/dhtmlxGrid/codebase/skins/dhtmlxgrid_dhx_skyblue.css" rel="stylesheet" type="text/css" />
    <style type="text/css">
        html, body
        {
            width: 100%;
            height: 100%;
            overflow: hidden;
            margin: 0px;
            background-color: #EBEBEB;
        }
    </style>
    <script type="text/javascript">
        function doOnLoad() {
            var mygrid;

            mygrid = new dhtmlXGridObject('gridbox');
            mygrid.setImagePath("codebase/dhtmlxGrid/codebase/imgs/");
            mygrid.setHeader("Product, Description");
            mygrid.setInitWidths("*,*");
            mygrid.setColTypes("edtxt,ed");
            mygrid.setColSorting("connector,connector");
            mygrid.init();
            mygrid.loadXML("gridBasicSQLConnector.ashx");
        }
    </script>
</head>
<body onload="doOnLoad()">
    <form id="form1" runat="server">
        <div id="gridbox" style="width:600px; height:200px; background-color:white; overflow:hidden;"></div>
    </form>
</body>
</html>

Thank you

Hello, here is the sample
ConnectorsStoredProcedure.zip (836 KB)

Thank you!

Hi , I tried the example code and get the error message here.
Error 1 Could not load type ‘ConnectorsStoredProcedure.Global’. C:\Users\liqin\Downloads\ConnectorsStoredProcedure\ConnectorsStoredProcedure\Global.asax 1

Hi,
maybe this will help

stackoverflow.com/questions/1598 … pplication

Hi Aliaksandr,

Thanks a lot for the sample. It is working perfectly fine for my requirement.
Is there any sample which would allow us to perform CRUD operation on the grid using popup and ASP.NET / SQL Server?

Thanks in advance,
Regards,
Sandy