Click here to Skip to main content
13,050,450 members (82,984 online)
Rate this:
Please Sign up or sign in to vote.
See more:
Hi, iam using jqgrid using json result but grid is not populating plz help me
here is my code
for controller:
public JsonResult GetEmployeeData()
            List<models.empdetails> emp = new List<models.empdetails>();
            string query = "select * from EmpDetail where StatusTypeId=1  order by EmpId DESC";
            SqlCommand cmd = new SqlCommand(query, con);
            SqlDataAdapter da = new SqlDataAdapter(cmd);
            cmd.CommandType = CommandType.Text;
            DataSet ds = new DataSet();
            foreach (DataRow dr in ds.Tables[0].Rows)
                emp.Add(new Models.EmpDetails()
                    Name = dr[0].ToString(),
                    EmpId = Convert.ToInt32(dr[1].ToString()),
                    Salary = Convert.ToInt32(dr[2].ToString()),
                    Address = dr[3].ToString(),
                    ZipCode = Convert.ToInt32(dr[4].ToString()),
                    PhoneNumber = Convert.ToInt32(dr[5].ToString()),
                    Permanent = Boolean.Parse(dr[7].ToString()),
                    Birthday = Convert.ToDateTime(dr[8].ToString()),
                    Country = dr[9].ToString()
            return Json(emp, JsonRequestBehavior.AllowGet);

$(document).ready(function () {
            dataType: 'json',
            height: 250,
            mtype: 'Get',
            url: '/Home/GetEmployeeData',
            colNames: ['Name', 'Address', 'Salary', 'PhoneNumber', 'Zipcode', 'Permanent', 'Birthday', 'Country'],
            colModel: [{ name: 'Name', index: 'Name', width: 80 },
                       { name: 'Address', index: 'Address', width: 100 },
                       { name: 'Salary', index: 'Salary', width: 60 },
                       { name: 'PhoneNumber', index: 'PhoneNumber', width: 75 },
                       { name: 'ZipCode', index: 'ZipCode', width: 75 },
                       { name: 'Permanent', index: 'Permanent', width: 60 },
                       { name: 'Birthday', index: 'Birthday', width: 75 },
                       { name: 'Country', index: 'Country', width: 100 }
            cation: 'EmplyoeeDetails',
            pager: $('#pager'),
            sortdesc: 'desc',
            viewrecords: true
Posted 7-May-13 23:40pm
Updated 8-May-13 5:43am
Member 9581488 8-May-13 11:57am
Is your method returns the required data?
cation: 'EmplyoeeDetails', // it should be caption:
Are you getting any error in console?
Tadit Dash 8-May-13 12:29pm
Please check FireBug Console tab in FireFox, if there are any errors/exceptions.
Member 9507975 26-Sep-13 21:38pm
this may not be a error but is definately a mistake

this is wroing
pager: $('#pager'),

should be

pager: #pager,

dataType: 'json',

should be

datatype: 'json',

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

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web01 | 2.8.170713.1 | Last Updated 8 May 2013
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100