Search code examples
c#web-servicesdatasetdatalist

Combining two results of datasets into one


I have created a webservice which returns two datasets(return type) as results. Is it possible to combine two datasets results into one so that I can display it on one datalist? I try using arraylist but it returns nothing in datalist.

GetDepartureFlightsDetails() and getDepartureFlights() both returns a dataset values.

Below is the method i use to retrieve the webservice results.

public ArrayList GetDepartureFlightsDetails(String departurecountry, String arrivalcountry, DateTime departuredate)   
{
    DLSA datalayerTS = new DLSA();
    DLJS datalayerJW = new DLJS();

    ArrayList array = new ArrayList();

    array.Add(datalayerSA.GetDepartureFlightsDetails(departurecountry, arrivalcountry, departuredate));
    array.Add(datalayerJW.getDepartureFlights(departurecountry, arrivalcountry, departuredate));
    return array;
}

Solution

  • You can use the DataSet.Merge method:

    firstDataSet.Merge(secondDataSet);
    

    Update:

    public DataSet GetDepartureFlightsDetails(String departurecountry, String arrivalcountry, DateTime departuredate)
    {
        DLSA datalayerTS = new DLSA();
        DLJS datalayerJW = new DLJS();
    
        var firstDataSet = datalayerSA.GetDepartureFlightsDetails(departurecountry, arrivalcountry, departuredate));
        var secondDataSet = datalayerJW.getDepartureFlights(departurecountry, arrivalcountry, departuredate));
        firstDataSet.Merge(secondDataSet);
    
        return firstDataSet;
    }