Click here to Skip to main content
15,878,852 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I am unable to understand what is the error.
why my output screen is blank??
please can anyone help!!!!
I have provided the aspx and cs.
stucked at this problem from hours...
Sql database connection to jqgrid

What I have tried:

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default2.aspx.cs" Inherits="Default2" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">

<html xmlns="">
<head runat="server">
     <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge"/>
    <meta name="viewport" content="width=device-width,initial-scale=1"/>
      <link rel="stylesheet" href=""/>
    <link rel="stylesheet" href=""/>
    <script src=""></script>
    <script src=""></script>

    <script type="text/javascript">
        $(document).ready(function () {
               source = {
                datatype: "xml",
                datafields: [
                { name: 'Emp_Code'},
                { name: 'Mgr_Code'},
                { name: 'Name'},
                { name: 'Designation'},
                { name: 'Login'},
                { name: 'Password'},
                { name: 'Zone_Code'}
                async: false,
                record: 'Table',
                url: 'Default2.aspx/GetCustomers'
            var dataAdapter = new $.jqx.dataAdapter(source,
                {  contentType: 'application/json; charset=utf-8'}   
                source: dataAdapter,
                theme: 'classic',
                columns: [
                    { text: 'Emp_Code', dataField: 'Emp_Code', width: 250 },
                    { text: 'Mgr_Code', dataField: 'Mgr_Code', width: 150 },
                    { text: 'Name', dataField: 'Name', width: 180 },
                    { text: 'Designation', dataField: 'Designation', width: 180},
                    { text: 'Login', dataField: 'Login', width: 80 },
                    { text: 'Password', dataField: 'Password', width: 100},
                     { text: 'Zone_Code', dataField: 'Zone_Code', width: 100}
    <form id="form1" runat="server">
    <table id="jqxgrid"></table>

/// the .CS that I have used
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.Services;
using System.Web.Script.Services;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
using System.Web.Script.Serialization;

    public partial class Default2 : System.Web.UI.Page
        protected void Page_Load(object sender, EventArgs e)
            if (!IsPostBack)

        [ScriptMethod(UseHttpGet = true, ResponseFormat = ResponseFormat.Xml)]
        public static string GetCustomers()
            string query = "SELECT * From Employee_Master ";
            SqlCommand cmd = new SqlCommand(query);

            DataSet data = GetData(cmd);

            System.IO.StringWriter writer = new System.IO.StringWriter();
            data.Tables[0].WriteXml(writer, XmlWriteMode.WriteSchema, false);
            return writer.ToString();
        private static DataSet GetData(SqlCommand cmd)
            string strConnString = ConfigurationManager.ConnectionStrings["sqlcon"].ConnectionString;
            using (SqlConnection con = new SqlConnection(strConnString))
                using (SqlDataAdapter sda = new SqlDataAdapter())
                    cmd.Connection = con;
                    sda.SelectCommand = cmd;
                    using (DataSet ds = new DataSet())
                        return ds;
Updated 14-Jul-22 19:34pm

I cannot be certain but I think that the following code is not correct:
using (DataSet ds = new DataSet())
    return ds;

The using statement is mostly for read only objects which need to be closed and disposed as the block completes. In your case you are trying to fill the DataSet and preserve it for the return value. Change the code to the following and see if that improves things:
DataSet ds = new DataSet();
return ds;
Share this answer
Member 15676878 14-Jul-22 4:52am    
I have tried to change the code as you said, but still output is not showing! Can you please help.
Richard MacCutchan 14-Jul-22 5:18am    
Sorry, I have no way of testing your code. You need to do some debugging to find out what is happening. The first step is o check that the DataSet is getting filled and being passed back to the calling routine in the GetCustomers method. Also I notice that in your Page_Load method you call GetCustomers, but you do not capture the XML data returned from ; why not?
Member 15676878 14-Jul-22 5:23am    
I have debugged and checked the dataset is being filled with my sql data but just output is not showing,
and further improvisation that I have done are; cleared the page_load method but still no output! what should i do ? should i write.xml in page_load??
Richard MacCutchan 14-Jul-22 6:07am    
Yes, because as stated in my message you are not capturing it in your Page_Load method. You need to debug all the way to the point where it should be displayed.
Member 15676878 15-Jul-22 1:35am    
thanks for the help my code is working now... i found out that i missed the script links!
///// I have forgotten to add the links but now as i added the links, my output is coming completely fine!!!////
Thanks For the help!!

<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge"/>
<meta name="viewport" content="width=device-width,initial-scale=1"/>
<link href="Styles/jqx.base.css" rel="stylesheet" type="text/css" />
<script src="Styles111/bootstrap.min.js" type="text/javascript"></script>
<script src="jsfolder/jquery.leanModal.min.js" type="text/javascript"></script>
<link href="Styles/jqxmenustyle.css" rel="stylesheet" type="text/css" />
<link href="Styles/jqx.classic.css" rel="stylesheet" type="text/css" />
<script src="Scripts/jquery-1.7.1.min.js" type="text/javascript"></script>
<script src="Scripts/jqxcore.js" type="text/javascript"></script>
<script src="Scripts/jqxbuttons.js" type="text/javascript"></script>
<script src="Scripts/jqxdata.js" type="text/javascript"></script>
<script src="Scripts/jqxgrid.js" type="text/javascript"></script>
<script src="Scripts/jqxgrid.selection.js" type="text/javascript"></script>
<script src="Scripts/jqxmenu.js" type="text/javascript"></script>
<script src="Scripts/jqxscrollbar.js" type="text/javascript"></script
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900