views:

77

answers:

1

I'm looking for a method or an event that would get fired when a row in a datatable is accessed.

I have a datatable with several thousand rows, and an image in at least one of the columns. I want to dynamically load and unload the image from the row when it gets accessed.

I haven't seen any documentation that suggests that it's there, but I thought I'd post and see if anyone knows.

+2  A: 

The problem is that you have to define "accessed". If you're talking about "displayed" then you probably don't really want to tie into the DataTable but rather the grid (or list or whatever is displaying the DataTable). If you mean "touched" then you have a trickier problem. There's no event on the DataTable or DataRow objects for you to tie into, but the items in a DataRow are all objects. Which means you could probably do something on the "cell" level, particularly if you're using WPF and can substitute in a System.Windows.Controls.Image object.

I'd be careful, though. This sounds like it could be a case of premature optimization.

Jacob Proffitt
I'm definitely open to an alternative to working with the large dataset. The real problem comes from the fact that the datatable is a composite of information from multiple data sources.
JoelHess
DataSet objects (at least post .Net 1.1) are relatively efficient so the only real limiting factor is likely to be memory. i.e. performance isn't likely to be a problem, at least not in a way that'll be fixed by late-loading and early disposal of images.That said, I don't have skin in the issue and it's been a couple of years since I worked with datasets that large.
Jacob Proffitt