我无法设法在asmx Web服务中获得正确的json响应数据结构是使用DataContract和DataMember属性定义的,但指定DataMember Name doesn' T改变的响应数据你有什么想法,这里的代码(这是对的jqGrid):?Asmx Web服务JSon响应没有考虑DataMember(Name =
/// <summary>
/// a row of the jquery table
/// </summary>
[DataContract()]
public class RowElement
{
/// <summary>
/// an Id for each row
/// </summary>
[DataMember(Name = "id")]
public string Id { get; set; }
/// <summary>
/// the table of cells
/// </summary>
[DataMember(Name = "cell")]
public string[] Cell { get; set; }
}
/// <summary>
/// the table for jquery
/// </summary>
[DataContract()]
public class MainGrid
{
/// <summary>
/// the number of pages
/// </summary>
[DataMember(Name = "total")]
public string Total { get; set; }
/// <summary>
/// the num of the actual Page?
/// </summary>
[DataMember(Name = "page")]
public string Page { get; set; }
/// <summary>
/// nb of elements in all the table
/// </summary>
[DataMember(Name = "records")]
public string Records { get; set; }
/// <summary>
/// the list of Rows
/// </summary>
[DataMember(Name = "rows")]
public RowElement[] Rows { get; set; }
}
/// <summary>
/// method for jquery
/// </summary>
/// <param name="numRows">nb of Rows</param>
/// <param name="Page">nb of Page</param>
/// <param name="sortField">the column for the sort</param>
/// <param name="sortOrder">the order of the sort</param>
/// <param name="searchString">the filter if defined</param>
/// <returns>the grid returned</returns>
[WebMethod]
[ScriptMethod(ResponseFormat = ResponseFormat.Json)]
////int Page, int pageSize, string sortIndex, string sortDirection
public MainGrid jQGridDataASMX(int? numRows, int? page, string sortField, string sortOrder, string searchString)
{
...
MainGrid mg = new MainGrid();
return mg;
}
客户端的数据仍然是编号,而不是ID