尝试使用saveRow()时jqGrid无效的JSON原语

时间:2011-06-10 08:49:03

标签: asp.net json webforms jqgrid

我们正在使用ASP.NET Webforms和jqGrid。从Web服务到网格检索数据没有问题。但是,在尝试使用saveRow时,我们会遇到异常。我认为这是由于无效的json,但使用内置的saveRow()我会猜到网格会使它成为有效的json。使用fiddler2并且调用使用“application / json; charset = utf-8”

调用saveRow:

$("#SupplierSettingTable").jqGrid('saveRow', rowNumber, true, '<%= ResolveClientUrl("~/Services/SupplierSettingService.asmx/SetSupplierSettingItem")%>' );

以下是例外:

{"Message":"Invalid JSON primitive: AccountGroupName.","StackTrace":" at System.Web.Script.Serialization.JavaScriptObjectDeserializer.DeserializePrimitiveObject()\r\n at System.Web.Script.Serialization.JavaScriptObjectDeserializer.DeserializeInternal(Int32 depth)\r\n at System.Web.Script.Serialization.JavaScriptObjectDeserializer.BasicDeserialize(String input, Int32 depthLimit, JavaScriptSerializer serializer)\r\n at System.Web.Script.Serialization.JavaScriptSerializer.Deserialize(JavaScriptSerializer serializer, String input, Type type, Int32 depthLimit)\r\n at System.Web.Script.Serialization.JavaScriptSerializer.Deserialize[T](String input)\r\n at System.Web.Script.Services.RestHandler.GetRawParamsFromPostRequest(HttpContext context, JavaScriptSerializer serializer)\r\n at System.Web.Script.Services.RestHandler.GetRawParams(WebServiceMethodData methodData, HttpContext context)\r\n at System.Web.Script.Services.RestHandler.ExecuteWebServiceCall(HttpContext context, WebServiceMethodData methodData)","ExceptionType":"System.ArgumentException"}

帮助表示赞赏......

1 个答案:

答案 0 :(得分:1)

您应该验证是否使用

ajaxRowOptions: { contentType: "application/json" }

serializeRowData: function (data) { return JSON.stringify(data); }

jqGrid参数。有关详细信息,请参阅thisthis个答案。

如果它没有帮助,您应该在您的问题中包含将发送到服务器和响应的确切数据。您将获得有关FiddlerFirebug的信息。