Click here to Skip to main content
11,923,958 members (65,923 online)
Click here to Skip to main content
Add your own
alternative version

Tagged as


8 bookmarked

JQGrid With ASP.NET Using ASMX Web Services

, 4 Oct 2011 CPOL
Rate this:
Please Sign up or sign in to vote.
Use Of JQGrid In ASP.NET Using ASMX Web Services(Paging,Sorting,Add/Edit/Del Functions)
The grid is a Ajax-enabled JavaScript control that provides a solution for representing tabular data on the web. Since the grid is a client-side solution and loading data dynamically through Ajax callbacks, it can be integrated with any server side technology.

I found that many are trying to use JQgrid with ASP.NET. Even I tried to implement jqgrid with basic functionalities like paging, sorting, editing row, adding row, deleting row by searching in Google.
Finally, I created one working example. So I thought of sharing it thinking that someone might find it useful.

Here I am not explaining from scratch. There are many sources for jqgrid beginners (you can get information about which plugins you need to refer to use jqgrid, basic examples and demos at
I would like to mention some important things which I found.
I have attached my code.
I have a Table in my database called ‘Person’ with the structure as below:
Column Name DataType
PID int Primary Key
FirstName Nvarchar
LastNAme Nvarchar

To run the project, create Person table as above and give your DB connection string.
  1. url: '/WebService.asmx/GetListOfPersons1': This method calls to load data to the grid.
  2. editurl: '/WebService.asmx/EditRow': This method calls while adding new row, updating the row and deleting the row.
  3. Following setting for Add/Edit/Del operations.
    1. To post the data to server as object, you have to set content type to "application/json".
    2. While deleting row, grid posts only grid rowid and oper variables.
      To delete row at server side, we need some column values example primary key of the table. To achieve that, these settings should be done for delete operation.

      onclickSubmit: function (eparams) {
                          var retarr = {};
                          var sr = jQuery("#contactsList").getGridParam('selrow');
                          rowdata = jQuery("#contactsList").getRowData(sr);
                          retarr = { PID: rowdata.PID};
      jQuery.extend(jQuery.jgrid.edit, {
                      closeAfterEdit: true,
                      closeAfterAdd: true,
                      ajaxEditOptions: { contentType: "application/json" },
                      serializeEditData: function (postData) {
                          var postdata = { 'data': postData };
                          return JSON.stringify(postdata); ;
                  jQuery.extend(jQuery.jgrid.del, {
                      ajaxDelOptions: { contentType: "application/json" },
                      onclickSubmit: function (eparams) {
                          var retarr = {};
                          var sr = jQuery("#contactsList").getGridParam('selrow');
                          rowdata = jQuery("#contactsList").getRowData(sr);
                          retarr = { PID: rowdata.PID};
                          return retarr;
                      serializeDelData: function (data) {
                          var postData = { 'data': data };
                          return JSON.stringify(postData);


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


About the Author

Rachana BG
United States United States
No Biography provided

You may also be interested in...

Comments and Discussions

GeneralMy vote of 1 Pin
TomReit19-Nov-14 23:17
memberTomReit19-Nov-14 23:17 
AnswerJqgrid with working code Pin
Atul Savaliya17-Jun-13 1:59
memberAtul Savaliya17-Jun-13 1:59 
GeneralMy vote of 5 Pin
iamvova16-Dec-12 13:45
memberiamvova16-Dec-12 13:45 
QuestionDo not allow these type of posting Pin
Sen K Mathew8-May-12 23:15
memberSen K Mathew8-May-12 23:15 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.151125.3 | Last Updated 4 Oct 2011
Article Copyright 2011 by Rachana BG
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid