DataColumn.Expression complex calculations

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi.
Does anybody know how to perform complex calculations using the
DataColumn.Expression property?
Specifically, I'm trying to calculate the difference between a DateTime
column and the current date:
DateTime.Now.Subtract(certainDate).TotalDays

Is there a way to integrate custom functions in this property?
 
Hi Amir,

I think that it is best to manually perform such calculations in this case.
Refresh them in ColumnChanged event and do an DataRowAcceptChanges if he row
wasn't modified before.
 
Amir,

In my opinion is the expression not to for doing *complex* calculations.

http://msdn.microsoft.com/library/d...fSystemDataDataColumnClassExpressionTopic.asp

On this page is only with this sample given how to use dates
"Birthdate < #1/31/82#"

Be aware that because every thing in dotNet is nicely globalized done, you
have to investigage how it has to be used with computers outside the USA,
because this is a typical USA notation and I don't know if it is for
computers (beside English speaking Canada) in the rest of the world
accoording those culture/language notations..

I hope this helps,

Cor
 
Hi,

What you could do is to catch an event of the DataTable when DataRow inside
of it has been changed and calculate new date inside of this event. Then
assign value to the column. At least it will work in all the cases when row
was modified
 
Back
Top