Using jqGrid user data

I have jqGrid in an ASP.Net MVC view. I want to use to pass the value of a hidden text control on the page as an additional parameter to the jqGrid method.

I have the following hidden text box:

<div> <%= Html.Hidden("contactId", Model.ContactId) %> </div> 

and I want to do something like:

 userdata: {contactId : jQuery('#contactId')} 

in jqGrid call. The Action Control method has the following signature:

 public ActionResult SearchResult(string sidx, string sord, int page, int rows, object userdata) 

But when I run it, userdata in C # code just says System.Object when I test it in the debugger, and I don’t think I can extract anything useful from it.

Any ideas I made a mistake in?

+6
jquery asp.net-mvc jqgrid
source share
1 answer

The jqGrid property you want is postData. UserData goes the other way.

Change your call to JqGrid to include:

 postData: {contactId : jQuery('#contactId').val()} 

Then change the signature of your action to get contactId:

 public ActionResult SearchResult(string sidx, string sord, int page, int rows, int contactId) 

I guessed about the type. Use real type instead of int.

+6
source share

All Articles