Мне не удается получить правильный ответ json в веб-сервисе asmx.Структура данных определяется с помощью атрибутов DataContract и DataMember, но указание имени DataMember не изменяет данные ответа.Есть ли у вас какие-либо идеи?Вот код (это для jqgrid):
/// <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, а не id.