M
MR
How can I re-sort a the rows in a data table?
Here is the example:
I read a data set that is sorted by probability. Then some algorithm
recalculates the probability field in each record.. As a result of the new
probability value, the rows very often are no longer sorted. to continue the
processing i need to have the rows sorted based on the new probability.
If i just do dataTable.DefaultView.Sort = "[Probability]", the rows are not
sorted.
however if i create a view based on the default view, and set the sort (or
visa versa), the rows are sorted but then i can't use the view to update the
database (even if i create a datatable form this view). i get an error that
says that something like i need to supply an insert statement in the update.
it must see the records in the dataview as new rows and not as modified row.
the only way i am able to have a data table that is correctly sorted is to
do an update with the changes and then re-query to create a new datatable.
there has got to be a better way to do this.
does anyone have any ideas?
m
Here is the example:
I read a data set that is sorted by probability. Then some algorithm
recalculates the probability field in each record.. As a result of the new
probability value, the rows very often are no longer sorted. to continue the
processing i need to have the rows sorted based on the new probability.
If i just do dataTable.DefaultView.Sort = "[Probability]", the rows are not
sorted.
however if i create a view based on the default view, and set the sort (or
visa versa), the rows are sorted but then i can't use the view to update the
database (even if i create a datatable form this view). i get an error that
says that something like i need to supply an insert statement in the update.
it must see the records in the dataview as new rows and not as modified row.
the only way i am able to have a data table that is correctly sorted is to
do an update with the changes and then re-query to create a new datatable.
there has got to be a better way to do this.
does anyone have any ideas?
m