I have a web service method which i’d like to return multiple rows from a datatable.
I am familiar with returning values from web service methods but not multiple rows from a datatable. What is the best way to go about doing this? Do I need to return an array or list<>?
My code method is setup like this.
[WebMethod]
public void UpdateBold(int count, float lat, float lng)
{
DataTable dt = new Gallery().DisplayNearestByLatLong(count, lat, lng);
// return code here
}
You can create new type for your data table item and return array of this data
for Ajax:
for consuming see http://encosia.com/2008/03/27/using-jquery-to-consume-aspnet-json-web-services/
but you should make your webservice to serialize JSON, for this see
http://msdn.microsoft.com/en-us/library/bb763183.aspx