2012-03-21 53 views
0

我有一个JQGrid,它在加载时工作正常。但我想发送一些额外的数据到一个wcf服务。我试过editData,Serializeeditdata但无法做到这一点。任何人都可以帮助我发送它。我搜索并尝试了很多并且实施,但它没用。如果我为我的保存方法添加参数jqgrid抛出错误。JQGrid在编辑期间发布数据

jQuery(document).ready(function() { 
      jQuery("#grid").jqGrid({ 
       url: "../Service.svc/GetData", 
       data: JSON.stringify(params),`enter code here` 
       dataType: "json", 
       type: "POST", 
       contentType: "application/json; charset=utf-8", 
       colNames: ['Id', 'Value'], 
       colModel: [{ name: 'Id', index: 'Id', width: 1, align: 'left', editable: false}, 
         { name: 'Value', index: 'Value', width: 270, align: 'left', editable: true}, 
         ],     
       pager: jQuery('#pageNavigation'),    
       editurl: "../Service.svc/SaveData", 
       loadError: ShowError 
      }).navGrid('#pageNavigation', { edit: true, add: true, del: true, search: false }, //options 
       {// edit options 
       editData: {firstName: 'Test'}, 
       height: 100, width: 230, reloadAfterSubmit: true, closeOnEscape: true 
      } 
     }); 

// WCF CODE

<WebInvoke(Method:="POST", BodyStyle:=WebMessageBodyStyle.WrappedRequest, ResponseFormat:=WebMessageFormat.Json)> 
     Public Function GetData As String Implements Iservice.GetData 
     End Function 

     Public Sub SaveData(ByVal firstName As String) Implements Iservice.SaveData 
     //Retreive name and Do Some operation 
     End Sub 

回答

0

难道你还需要一个<WebInvoke>属性装饰你的SaveData方法?你有这个,它不是你提供的代码的一部分?否则,您需要提供,以便您的方法可以作为WCF调用访问。

<WebInvoke(Method:="POST", BodyStyle:="...", ...)> 
Public Sub SaveData(ByVal firstName As String) Implements Iservice.SaveData 
//Retreive name and Do Some operation 
End Sub 
+0

我把它作为我在这里提到。它不断给我错误状态:内部服务器错误错误代码:500.不知道如何解决这个问题。 – 2012-03-22 13:09:32

+0

你是否能够浏览你的代码?听起来就像你在SaveData方法的某个地方有错误。 – 2012-03-22 13:41:39

+0

它甚至没有进入functin。我可以通过get方法并调试它。但在这里,只要我点击提交按钮,它就会给我这个错误。 – 2012-03-22 14:32:15