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

  • SEARCH
  • Home
  • 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 7762513
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T14:25:28+00:00 2026-06-01T14:25:28+00:00

I want to fill jqGrid from a stored procedure, there was 1 good example

  • 0

I want to fill jqGrid from a stored procedure, there was 1 good example is given at following link, but my problem is that I am not using model to retrieve data, any SOLUTION ?

I am using jqGrid + SQL Server 2008 + ASP.net MVC3 (c#)

Example of jqGrid filling by stored procedure with Model

Here by am giving the code that i am using currently

VIEW CODE

$(document).ready(function () {
        $('#History').jqGrid({
            //url from wich data should be requested
            url: '@Url.Action("UploadData")?entity=' + getEntity(),

            //type of data
            datatype: 'json',
            //url access method type
            mtype: 'GET',
            //columns names
            colNames: ['ID', 'File','Uploaded', 'By'],
            //columns model
            colModel: [
                            { name: 'ID', index: 'ID', align: 'left', editable: false },
                            { name: 'File', index: 'File', align: 'left', editable: false, formatter: "text", width: '105px' },
                            { name: 'Uploaded', index: 'Uploaded', align: 'left', editable: false, formatter: "text", width: '102px' },
                            { name: 'By', index: 'By', align: 'left', editable: false, formatter: "text", width: '78px' },
                          ],
            //pager for grid
            pager: $('#Historypager'),
            //number of rows per page
            rowNum: 15,
            //initial sorting column
            sortname: 'File',
            //initial sorting direction
            sortorder: 'asc',
            //we want to display total records count
            viewrecords: true,
            //Sets the caption for grid
            caption: 'Upload History',
            //grid height
            height: '100%'

        });

        $('#History').jqGrid('navGrid', '#Historypager', { add: false, del: false, edit: false, search: false });

        $('#History').jqGrid('hideCol', "ID");
        var dialogPosition = $(this).offset();
    });

CONTROLLER METHOD

public JsonResult UploadData(string sidx, string sord, int page, int rows, string entity)
        {
            int pageIndex = Convert.ToInt32(page) - 1;
            int pageSize = rows;
            var entitytype = Request.QueryString["entity"].ToString().Trim();
            var uploadlist = objEntities.Uploads.Where(u => u.TableName == entitytype).ToList().AsQueryable(); // fetches the data from upload table

            int totalRecords = uploadlist.ToList().Count(); // total records in the current table
            int totalPages = (int)Math.Ceiling((float)totalRecords / (float)pageSize); // counts the total no. of pages

            if (sord.Trim().ToLower() == "asc") // fetches data according the sorting order
                uploadlist = uploadlist.OrderBy(x => TypeHelper.GetPropertyValue(x, sidx)).Skip(pageIndex * pageSize).Take(pageSize);
            else
                uploadlist = uploadlist.OrderByDescending(x => TypeHelper.GetPropertyValue(x, sidx)).Skip(pageIndex * pageSize).Take(pageSize);

            // fetches data and sets it in JSON format
            var jsonData = new
            {
                total = totalPages,
                page = page,
                records = totalRecords,
                rows = (from b1 in uploadlist
                        select new
                        {
                            id = b1.ID,
                            cell = new string[] {
                                Convert.ToString(b1.ID),
                                b1.File,
                                Convert.ToString(b1.Uploaded),
                                Convert.ToString(b1.By)
                            }
                        }).ToArray()
            };

            return Json(jsonData, JsonRequestBehavior.AllowGet); // returns the data back to the jqgrid
        }

In this Example i’ve used LINQ demo, but now in new task i’ve to use Stored Procedure to fetch the data…

  • 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-01T14:25:29+00:00Added an answer on June 1, 2026 at 2:25 pm

    CONTROLLER CODE

    var uploadlist = SPforData(sidx, sord, page, rows /* , +other parameters */).ToList();
                    int totalRecords = 0;
                    foreach (var pr in uploadlist)
                    {
                        totalRecords = Convert.ToInt32(pr.Total);
                        break;
                    } // here I am fetching total number of records that have been returned from SP
    
            int totalPages = (int)Math.Ceiling((float)totalRecords / (float)pageSize); // counts the total no. of pages
    
            var jsonData = new
            {
                total = totalPages,
                page = page,
                records = totalRecords,
                rows = (from pr in uploadlist
                        select new
                        {
                            id = pr.ID,
                            cell = new string[] {
                                Convert.ToString(pr.ID),
                                Convert.ToString(pr.Name),
                                Convert.ToString(pr.Age),
                                Convert.ToString(pr.Qualification),
                            }
                        }).ToArray()
            };
    
            return Json(jsonData, JsonRequestBehavior.AllowGet); // returns the data back to the jqgrid
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to fill my ListView with data that's going to come from the
I want to fill an array in javascript that takes all the values out
I simply want to fill-up cells in my spreadsheet from a VBA function. By
I have an ImageButton that I want to fill its parent RelativeLayout container for
I Had Drop down list and I want to fill it with data from
here's my question, i want to fill the content div with white. BUT when
i want to fill the data of the charts from values i have in
i want to fill a combobox with data from the database when the page
I want to fill my jqGrid with this data: {total:1, page:1, records:1, rows:[ {id:1,
I want to fill a polygon shape that I have drawn via Core Graphics

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.