Find DataViews associated with a DataTable

  • Thread starter Thread starter Joe
  • Start date Start date
J

Joe

Is there a way to find all DataViews associated with a DataTable? I have a
method which sort of refreshes the DataTable property by assigning a
DataTable to the field the property points to. The problem is there are some
forms open that are using the DataTable in a DataView and those changes
don't take effect.
 
Hi,

You need to check from the opposite side -check which table belongs to
dataview. DataTable does not return information about associated DataViews
 
Although internally each DataTable maintains a list of associated
DataViews, this is not exposed publicly.
You can get the DataTable from a given DataView through the DataView.Table
property. And easy work around is to keep a list of all DataViews for a
given DataTable.

Can you describe why you require this scenario?

Andrew Conrad
Microsoft Corp
http://blogs.msdn.com/aconrad/default.aspx
 
Thanks for your response.

We have to refresh the underlying table every so often which is returned
from a call to a remote object. It would be nice to get a collection of all
DataViews using this table and reset their table property after the refresh
has been done.
The initial call and refresh looks something like this:

m_table = GetWorkTable();
....

// Later in the program we have a bunch of these
DataView dv = new DataView(m_table);

What I did was create an event in my class that does the refresh and in the
other classes that use this table I register for that event and do dv = new
DataView(m_table);

-Joe
 
DataViews are already automatically updated when an underlying table is
changed. Are you saying that the refresh is to create a new table or just
to change something in the original table?

Andrew Conrad
Microsoft Corp
 
Back
Top