Business logic per typed datatable

B

Blast

I want to validate my data at the typed dataset level and not at the
datagridview / ui level. Data validation is a business rule and as
such should be a different layer then the UI.

Basically, I have a class made for each datatable in my typed dataset.
The class has the abilitiy to fill a specific datatable, do searches
and join etc. I want to place my business logic in this class.
However, the only event I see for a type datatable is the rowchanged
event. I can't figure out how to get the change information per cell.
For example, if someone is changing a cell value from x to b, I want
to validate that change. So I need the proposed value and the existing
value of the cell before I allow it to be changed in the typed
datatable. Is this possible to do, have I overlooked an event for the
typed datatable?

-Watson
 
C

Cor Ligthert[MVP]

Watson,

AFAIK did you overlook nothing, when you want this you can check per Row as
the event for that is triggering, AFAIK is the cell change in a DataTable
not triggering.

Cor
 
B

Blast

Watson,

AFAIK did you overlook nothing, when you want this you can check per Row as
the event for that is triggering, AFAIK is the cell change in a DataTable
not triggering.

Cor

I guess i'm not sure how to figure out what the proposed value is and
what the new value is for each cell of the row. For example, when a
when I hook into a row changing event, how do I iterate through each
cell in that row and get the proposed value and original value?
 
B

Blast

You can hook into the DataRowChangeEventHandler of a datatable and get
notification when a row changes. However, I want to know which cell in
the row changed and what the proposed and original values are for that
cell - not the entire row itself. I can't see how to do this....
 
B

Blast

Ah, I think this works to find out if the current and proposed values
are different for a cell in the row changing event:

e.Row["Col Name", DataRowVersion.Original] == e.Row["Col Name",
DataRowVersion.Proposed];
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top