Data conversion and manipulation
Hia all,
Hoping you're all having a great festive season !!
Quick question to pose :-
I've a DataTable that has a single column and houses data in string format (as imported from external files). I'm now moving this data to a secondary DataTable and would like to apply some conversion / manipulation in the process.
I'd like to do the following :-
- Convert a column in DataTable2 to Decimal
- Read the string data from DataTable1, convert it to a decimal datatype, multiply the resulting value by 100 and apply the Absolute mathematical function.
- Insert the result into DataTable2
I can do each of the functions (multiplication, Absolute, etc.) independantly on static data (ie:- not dynamic data from a DataTable) and can copy data back & forth between the DataTables. The issue I have is doing all in a single step.
ie:-
foreach (DataRow row in DataTable1.Rows)
{
decimalVal = System.Convert.ToDecimal(row);
decimalVal = (decimalVal * 100);
abs = Math.Abs(decimalVal);
DataTable2.ImportRow(abs);
}
Naturally the above does not work but hopefully gives an idea as to what I'm attempting to do.
Any help / pointers would be really useful.
Thanks