public void Location(int watershedId) { DataSet locationDataSet = ClassFunctions.GetLocationsByWatershed(watershedId); List <Location> locationList = new List <Location>(); for (int i = 0; i < locationDataSet.Tables[0].Rows.Count; i++) { DataRow dataRow = locationDataSet.Tables[0].Rows[i]; Location location = new Location { Latitude = Convert.ToDouble(dataRow["Latitude"]), Longitude = Convert.ToDouble(dataRow["Longitude"]), SensorName = Convert.ToString(dataRow["SensorName"]), LocationID = Convert.ToInt32(dataRow["LocationID"]) }; locationList.Add(location); } JavaScriptSerializer js = new JavaScriptSerializer(); Context.Response.Clear(); Context.Response.ContentType = "application/json"; Context.Response.Write(js.Serialize(locationList)); }