I have a DataTable that is in a singleton class; the data is loaded
from an XML file, or created by the user at runtime in a DGV. I have
no problems with adding or deleteing rows at first. My problem occurs
when I close that form and populate the data in a new form by binding
a DGV in the new form to the same datatable/singleton class.
In the new form, if a user then tries to delete a row that was
previously added (in the first form), there are no problems. But if
they add a new row (through the datagridview), and then try to delete
that row, I get an error like this: "Error: Index 6 does not have a
value." And, the error keeps looping and popping up, freezing the
application.
I am wondering if my use of a singleton class is causing the problem.
If there is a better way to preserve the same class instance (with its
datatable) through my entire project besides a singleton, I would be
open to a change! My datatable is not tied to an external database,
as I am only keeping track of small amounts of data for a short term.
Any help would be appreciated - I'm a novice C#/.NET programmer.
Thanks,
Nathan
|