Guys I am taking the values in array of object and hitting the webmethod from ajax but I am not able to get the key and values of that array. Below is my ajax code
var ShedulerTableCount = $('#dvSave table').length;
var ShedulersData = [];
ShedularCount = new Object({ ShedulerCount: $('#txtTimeSeries').val() })
ShedulersData.push(ShedularCount);
for(var k=1; k <= ShedulerTableCount ; k++)
{
var tableId = $('#tblTimeInterval' + k);
tableId.find('tbody tr').each(function (i, el) {
Shedularobj = new Object({ ShedularName:'',InterVal: '', TimeSeries: '', LockingPeriod: '', TradeDuration: '', Min: '', Max: '', Touch: '', NoTouch: '', IPG: '', IPGDeduction: '', Closeable: '', txtTimeSeries: '', txtGap: '', txtRollingInterval:'' });
var $tds = $(this).find('td');
Shedularobj.ShedularName = 'sheduler ' + k;
Shedularobj.InterVal = $tds.find('label').eq(0).text();
Shedularobj.TimeSeries = $tds.find('label').eq(1).text();
Shedularobj.LockingPeriod = $tds.find('input').eq(0).val();
Shedularobj.TradeDuration = $tds.find('input').eq(1).val();
Shedularobj.Min = $tds.find('input').eq(2).val();
Shedularobj.Max = $tds.find('input').eq(3).val();
Shedularobj.Touch = $tds.find('input').eq(4).val();
Shedularobj.NoTouch = $tds.find('input').eq(5).val();
Shedularobj.IPG = $tds.find('input').eq(6).val();
Shedularobj.IPGDeduction = $tds.find('input').eq(7).val();
Shedularobj.Closeable = $tds.find('input').eq(8).val();
Shedularobj.txtTimeSeries = $('#txtTimeSeries').val();
Shedularobj.txtGap = $('#txtGap').val();
Shedularobj.txtRollingInterval = $('#txtRollingInterval').val();
ShedulersData.push(Shedularobj);
});
}
$.ajax({
type: "POST",
url: "BinarySetting.aspx/SaveShedulers",
data: "{ShedulersData:" + JSON.stringify(ShedulersData) + "}",
contentType: 'application/json; charset=utf-8',
success: function (XMLHttpRequest, textStatus, errorThrown) {
alert('Success');
},
error: function (result) {
alert('error');
}
});
And this is my c# code from where I want to fetch the key and value of the object:
[WebMethod]
public static string SaveShedulers(object[] ShedulersData)
{
object objCount = ShedulersData[0];
// System.Reflection.PropertyInfo pi = objCount.GetType().GetProperty("Value");
var ss = objCount.GetType().GetProperties().Single(pi => pi.Name == "ShedularCount").GetValue(objCount, null);
return "ss";
}
I am also going to attach the screenshot to understand the scenario more clearly:

ShedulersData[0].KeyandShedulersData[0].Value