gautam_reddyc
asked on
Adding a row to Datatable - urgent help needed
Hi,
I have a datatable with 2 columns "LONG" and "SHORT". before binding to grid, i need to add one more column "NET" .
NET = LONG - SHORT.
I need to calculate NET value by substracting short from long and I have to handle NULL values too if in case short or long is null.
Finally, my datatable shd be
long short Net
2 1 1
3 3 0
Please someone help me... I tried dng this bt I am missing something. i am not getting exaclty the way i am looking for. Please help me...
Thanks...
I have a datatable with 2 columns "LONG" and "SHORT". before binding to grid, i need to add one more column "NET" .
NET = LONG - SHORT.
I need to calculate NET value by substracting short from long and I have to handle NULL values too if in case short or long is null.
Finally, my datatable shd be
long short Net
2 1 1
3 3 0
Please someone help me... I tried dng this bt I am missing something. i am not getting exaclty the way i am looking for. Please help me...
Thanks...
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
sorry, my previous comment was wrong...
my question is: If "LONG" or "Short" values are NULL in database, the datatable is coming with empty row. In that case it's not working. In other words,
for ex: Long value is 2 and short is NULL in databse.. so in datatbale it is empty.. In that case NET is also coming as empty instead of 2 which is Long value... How to handle NULL values.. Please help me...
my question is: If "LONG" or "Short" values are NULL in database, the datatable is coming with empty row. In that case it's not working. In other words,
for ex: Long value is 2 and short is NULL in databse.. so in datatbale it is empty.. In that case NET is also coming as empty instead of 2 which is Long value... How to handle NULL values.. Please help me...
ASKER
thanks... it worked.. I am explicitly handling the NULL values...
ASKER
This will work if you have only one row. What if you have mutliple rows of long and short... If we do foreach for all rows, only first time we can add column. In the next statement we will get an error saying already column exists.
Please help me how to do this...