May i know how to sort a datatable?My code that show below got any problem?
why the datatable cant sort by qFundCode?
Firstly,my program is add sum datarow where qFundCode show below are to datatable.
qFunCode
WER
WER
WER
THS
THS
THS
AG
AG
AG
After this,i add another datarow where qFundCode show below are to datatable again.
qFundCode
WER
THS
AG
But when i sort the datatable by code show below.
If resultCheckEndOfYear = True Then
BalanceEndOfYear(dtDTBM)
dtDTBM = SortData(dtDTBM)
Else
Call BalanceData(dtDTBM)
End If
Private Function SortData(ByVal dtDTBM As DataTable) As DataTable
dtDTBM.DefaultView.Sort = String.Format("{0} {1}", "qFundCode", "ASC")
Return dtDTBM.DefaultView.Table
End Function
Private Sub BalanceEndOfYear(ByVal dtDTBM As DataTable)
The result cum out is like tis 1:
qFundCode
WER
WER
WER
THS
THS
THS
AG
AG
AG
WER
THS
AG
The correct result suppose is like below:
WER
WER
WER
WER(the datarow when add by the second times)
THS
THS
THS
THS(the datarow when add by the second times)
AG
AG
AG
AG(the datarow when add by the second times)
Hope sumbody can help me?Thanks