Using multiple dataviews of one datatable

I banged my head over a problem for a while a few months ago. I was using a lookup datatable for a dropdown and also trying to use it for a search (to get some more key info when the user selected an item for the drop down). But this was screwing up the display in the dropdown.

The problem makes so much sense. Even though I was using two separate dataviews from the datatable, changing the pointer (record position) in the dataview really changes the position in the datatable, thereby affecting any dataviews based on the table.

Since the table is only a lookup table, I was able to solve the problem by creating a dataview based on a copy – datatable.copy.dataview, and using THAT dataview for the 2nd function where I was doing the search.

I had the gratification of having two people who had also been struggling with this same problem ask me for help. One was using two separate views of a lookup table for two dropdownlists, the other was using two separate views of a lookup table for two datagrids.

I supposed if you need to edit, then you have deal with that copy, since it is not going to be updated automatically.

  Sign up for my newsletter so you don't miss my conference & Pluralsight course announcements!  

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.