problem with inserting into sorted DataView/DataTable

  • Thread starter Thread starter Dave Combs
  • Start date Start date
D

Dave Combs

Hi,

I've looked around, found nothing, and was wondering if
anybody had encountered the following problem.

I've got a DataView on which I set Sort = "name ASC".
That's fine--I've verified that the underlying DataTable
has all the rows in the original (unsorted) order, and
the rowViewCache in the DV has everything sorted and all
items refer to the right DT indexes. Then I add a
record to the DV that should end up in the middle of the
sorted list (i.e. at position 8 of 9 in the DV.) What
I've found is that when the DataTable adds the record
on 'EndEdit', rather than putting the record at the end
of the DataTable and inserting an item at position 8 in
the DV, it adds the record at position 8 in the DataTable,
but does nothing with the DataView. This means that now
two items in the DV are pointing at index 8 in the
DataTable, which is of course wrong. Anybody seen this
before, and have an idea how to get around it?

Thanks!
Dave Combs
 
Hmm, I'm not sure about this one. What happens if you reapply the sort to
the DV? Also, are you using any sort of filtering with the data view row
state?
 
Hi, Carsten,

I ended up fixing the problem by setting the sort to "",
then adding the row, then resetting the sort to it's
original value ("name ASC"). Setting to "" wiped out
the original sorted row cache in the view, adding the row
added it correctly at the end of the DataTable under the
view, and resetting the sort correctly reconstructed the
DataView's sorted list. It's gross, but it worked.

As far as filter, no, I wasn't using any filter--though
the DataView was actually a child view off another table.

Basically, I think that the DataView/DataTable insertion
code has a bug--it should be impossible to get two rows
in a DataView to point to the same underlying record, but
that's the state it was in. Can anybody confirm this as
an actual bug?

Thanks!
Dave
 
Back
Top