This is superb stuff! I used the custom base class option, created a public method and put your code in:
Code:
public string Json()
{
// your code
}now i just have to:
Code:
CustomersCollection col = new CustomersCollection();
col.LoadAll();
string json = col.Json();
and my jquery stuff is something like:
function LoadData()
{
$.getJSON("ajaxData.ashx",function(data)
{
$('#lblId').html(data.CustomerCollection.Customer[0].CustomerID);
$('#lblName').html(data.CustomerCollection.Customer[0].Name);
});
}
magic!
Note: in the code listed by paschoal1 i used the body of the method and used the Table property. so i replace 'dt' with 'Table'.
Sean Rock