c# - Sorting rows in a data table -
c# - Sorting rows in a data table -
we have 2 columns in datatable, so:
col1 col2 abc 5 def 8 ghi 3 we're trying sort datatable based on col2 in decreasing order.
col1 col2 ghi 8 abc 4 def 3 jkl 1 we tried this:
ft.defaultview.sort = "occr desc"; ft = ft.defaultview.totable(true); but, without using dataview, want sort datatable itself, not dataview.
i'm afraid can't in-place sort of datatable sounds want do.
what can create new datatable dataview create original datatable. apply whatever sorts and/or filters want on dataview , create new datatable dataview using dataview.totable method:
dataview dv = ft.defaultview; dv.sort = "occr desc"; datatable sorteddt = dv.totable(); c# sorting datatable
Comments
Post a Comment