简体   繁体   中英

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

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!

Something like this might work for you:

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

YourDataTableName = YourDatasourceName.YourDatasetName.DefaultView.ToTable(True, "YourColumnName")

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM