Calculated field question

  • Thread starter Thread starter Stefano Mostarda
  • Start date Start date
S

Stefano Mostarda

Hi there,

I have a question:

I need to add a calculated column to my datatable. I cannot use the
expression property of column as I have to perform some check on data of
each record before deciding what expression I have to apply.

As I come from Delphi development, it was quite easier because I have an
event allowing me to change the criteria for each record. Is there
something similar in ADO.NET?

Thanks in advance,

Stefano Mostarda MCP
Rome Italy
 
Hi Stefano,

You might use ColumnChanged or RowChanged to do the calculation.
 
If you're using SQL Server, you can create a trigger that performs the
calculations when the value is inserted. See the "Creating a Trigger"
and related topics in SQL BooksOnline. Creating it on the server is
going to be more reliable and performant than creating it in client
code.

--Mary
 
Thanks for reply,

your suggestion works up to a point. The problem is that when I change
the value of the calculated field, During loading, The rowchangedevent
fires again for that row. I can use a workaround for this but is not
correct, I think. Isn't there an event which is fired for each row
during loading?

Thanks again,
Stefano Mostarda MCP
Rome Italy
 
Hi Stefano,

Nope there isn't another one.
Just set a flag before changing somethinng within rowchanged and ignore
further calls while this flag is set.
 
Back
Top