Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9236079
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T07:12:11+00:00 2026-06-18T07:12:11+00:00

I am using Jqgrid to display my data into jqgrid using web services in

  • 0

I am using Jqgrid to display my data into jqgrid using web services in asp.net…but it is loading only when I am giving limit in the query.If I want to load all the data using second commneted query in the code then its not loading and giving error “”Message”:”Error during serialization or deserialization using the JSON JavaScriptSerializer. The length of the string exceeds the value set on the maxJsonLength property.”

Here is my entire Module Architecture…

index.aspx page…

<script type="text/javascript">
    $(function () {
        $("#table").jqGrid({
            datatype: function (pdata) { getData(pdata); },
            height: 500,
            colNames: ['username', 'ordinal', 'authcode', 'extension', 'trunk', 'dialnumber', 'dialdate', 'dialtime', 'duration', 'destination', 'price', 'toc'],
            colModel: [
                    { name: 'username', width: 100, sortable: true, align: 'center' },
                    { name: 'ordinal', width: 100, sortable: true, align: 'center' },
                    { name: 'authcode', width: 100, sortable: true },
                    { name: 'extension', width: 100, sortable: true, align: 'center' },
                    { name: 'trunk', width: 100, sortable: true, align: 'center' },
                    { name: 'dialnumber', width: 100, sortable: true, align: 'center' },
                    { name: 'dialdate', width: 100, sortable: true, align: 'center' },
                    { name: 'dialtime', width: 100, sortable: true, align: 'center' },
                    { name: 'duration', width: 100, sortable: true, align: 'center' },
                    { name: 'destination', width: 100, sortable: true, align: 'center' },
                    { name: 'price', width: 100, sortable: true, align: 'center' },
                    { name: 'toc', width: 100, sortable: true, align: 'center' }
                ],
            rowNum: 100,
            rowList: [100, 200, 300],
            pager: '#UsersGridPager',
            sortname: 'username',
            sortable: true,
            viewrecords: true,
            sortorder: 'asc',
            shrinkToFit: false,
            rownumbers: true,
            loadtext: 'Loading..'

        });
        jQuery("#table").jqGrid('navGrid', '#UsersGridPager', { add: false, edit: false, del: false, search: true, refresh: true });
    });


    function getData(pData) {
        $.ajax({
            type: 'POST',
            contentType: "application/json; charset=utf-8",
            url: '<%= ResolveClientUrl("~/WebService.asmx/GetListOfPersons") %>',
            data: '{}',
            dataType: "json",
            success: function (data, textStatus) {
                if (textStatus == "success")
                    ReceivedClientData(JSON.parse(getMain(data)).rows);
            },
            error: function (data, textStatus) {
                alert('An error has occured retrieving data!');
            }
        });
    }


    function ReceivedClientData(data) {
        var thegrid = $("#table");
        thegrid.clearGridData();
        for (var i = 0; i < data.length; i++)
            thegrid.addRowData(i + 1, data[i]);
    }


    function getMain(dObj) {
        if (dObj.hasOwnProperty('d'))
            return dObj.d;
        else
            return dObj;
    }
</script>

JsonHelper.cs file

// Convert Object to Json String
// <param name="obj">The object to convert</param>
// <returns>Json representation of the Object in string</returns>

public static string ToJson(object obj)
{
    return Newtonsoft.Json.JsonConvert.SerializeObject(obj);
}

public static List<Person> GetPersons()
{
    List<Person> persons = new List<Person>();
    string connectionString = "Server=localhost;Port=3306;Database=projecttt;UID=root;Pwd=techsoft;pooling=false";

    MySqlConnection conn;
    conn = new MySqlConnection(connectionString);
    conn.Open();

    string s = "SELECT username,ordinal,authcode,extension,trunk,dialnumber,dialdate,dialtime,duration,destination,price,toc FROM processeddata_table order by username limit 0,200";
   // string s = "SELECT username,ordinal,authcode,extension,trunk,dialnumber,dialdate,dialtime,duration,destination,price,toc FROM processeddata_table ";
    MySqlCommand cmd = new MySqlCommand(s,conn);

    cmd.ExecuteNonQuery();

    using (MySqlDataReader dr = cmd.ExecuteReader())
    {

        while (dr.Read())
        {
            persons.Add(new Person()
            {
                username = Convert.ToString(dr["username"]),
                ordinal = Convert.ToString(dr["ordinal"]),
                authcode = Convert.ToString(dr["authcode"]),
                extension = Convert.ToString(dr["extension"]),
                trunk = Convert.ToString(dr["trunk"]),
                dialnumber = Convert.ToString(dr["dialnumber"]),
                dialdate = Convert.ToString(dr["dialdate"]),
                dialtime = Convert.ToString(dr["dialtime"]),
                duration = Convert.ToString(dr["duration"]),
                destination = Convert.ToString(dr["destination"]),
                price = Convert.ToString(dr["price"]),
                toc = Convert.ToString(dr["toc"])

            });
        }

    }

    return persons;
}

}

PagedList.cs File

IEnumerable _rows;
int _totalRecords;
int _pageIndex;
int _pageSize;
object _userData;

public PagedList(IEnumerable rows, int totalRecords, int pageIndex, int pageSize, object userData)
{
    _rows = rows;
    _totalRecords = totalRecords;
    _pageIndex = pageIndex;
    _pageSize = pageSize;
    _userData = userData;
}

public PagedList(IEnumerable rows, int totalRecords, int pageIndex, int pageSize)
    : this(rows, totalRecords, pageIndex, pageSize, null)
{
}

public int total { get { return (int)Math.Ceiling((decimal)_totalRecords / (decimal)_pageSize); } }

public int page { get { return _pageIndex; } }

public int records { get { return _totalRecords; } }

public IEnumerable rows { get { return _rows; } }

public object userData { get { return _userData; } }

public override string ToString()
{
    return Newtonsoft.Json.JsonConvert.SerializeObject(this);
}

}

webservices.cs

[WebMethod]
[ScriptMethod]

public string GetListOfPersons()
{
    List<Person> persons = JsonHelper.GetPersons();
    return Newtonsoft.Json.JsonConvert.SerializeObject(new PagedList(persons, persons.Count, 1, persons.Count));
}

}

Person.cs

public string username { get; set; }
public string ordinal { get; set; }
public string authcode { get; set; }
public string extension { get; set; }
public string trunk { get; set; }
public string dialnumber { get; set; }
public string dialdate { get; set; }
public string dialtime { get; set; }
public string duration { get; set; }
public string destination { get; set; }
public string price { get; set; }
public string toc { get; set; }

Plz guys Help me .THanx in advance..

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T07:12:12+00:00Added an answer on June 18, 2026 at 7:12 am

    Why are you using ExecuteNonQuery() for select ? try ExecuteReader() method.

    See this :- Question on MaxJsonLength

    For local pagination loadonce: true can be used but still you will get the same error as you are trying to load too much data which is not advised. Also, ajax requests are used to handle small amount of data

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using jqGrid ( http://www.trirand.com/blog/ ) to display some read-only data. The resizeable
I finally got my asp.net grid to display data... But I need it to
I'm using jqGrid to display the results of a database query. The php script
I am using JQGrid to get the date from the RESTFul web services that
I'm currently using jqGrid to display data. Part of jqGrid's interface will give you
I am using jqgrid to display data i need Click Here to Edit in
I'm using JQGrid to display my data (the server returns xml). The data seems
I use jqGrid to display data which is retrieved using NHibernate. jqGrid does paging
I'm using ASP.Net MVC 4 with a jqGrid, and I'm trying to pass an
I'm using the jqGrid plugin to jQuery to display the results of database query

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.