I have a jqGrid on 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 a jqGrid method.
I have the following hidden text field:
<div>
<%= Html.Hidden("contactId", Model.ContactId) %>
</div>
and I want to do something like:
userdata: {contactId : jQuery('#contactId')}
in the jqGrid call. The Controller Action 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 the C# code just says System.Object
when I inspect it in the debugger, and I don't think I can get anythings useful out of it.
Any ideas where I have gone wrong?
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 take a contactId:
public ActionResult SearchResult(string sidx, string sord, int page, int rows,
int contactId)
I guessed at the type. Use the real type in place of int.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With