How to sort a column in dataset VB.NET having multiple sort conditions

Himanshu picture Himanshu · Nov 27, 2013 · Viewed 11.2k times · Source

I have a dataset in which there is a column contains various string type values like below:

Aircraft Crime Package Total Apartments DIC - Personnel

Now the requirement is that after applying sorting logic on this colum if there is a "Package Total" value in it then it must come at the top position on the Dataset and after that all other values should be in alphabatically sorted order like below:

Package Total Aircraft Apartments Crime DIC - Personnel

We have used in Database below logic which is working fine but can't figure it out how to do it on Dataset VB.net from Fronend side:

ORDER BY 
CASE WHEN UseCarrierAllocation = 0 THEN 
    CASE WHEN InvoiceItemLevel LIKE 'Package Total%' THEN 0 ELSE 1 
    END 
END, InvoiceItemLevel ASC

Any reply/idea will be helpful!

Answer

Hoh picture Hoh · Nov 27, 2013

Something like this might work for you:

    DataView dv = sDataSet.Tables("Table1").DefaultView;
    dv.Sort = "column1";