I have a button on my aspx page to download the gridview data to Excel. I am using SpreadsheetGear.dll. It worked nicely until the customer asked me to format the currency fields.
So this is my loop to format:
As I am stepping through debugging, I query this:Code:System.Data.DataTable dtWarranties; dtWarranties = ds.Tables[0]; // Format currency fields. double doubleOut; for (int i = 0; i < dtWarranties.Rows.Count; ++i) { for (int j = 3; j < 6; ++j) { if (Double.TryParse(Convert.ToString(dtWarranties.Rows[i].ItemArray[j]), out doubleOut)) dtWarranties.Rows[i].ItemArray[j] = String.Format("${0:0.00}", doubleOut); } }
? String.Format("${0:0.00}", doubleOut)
"$1569.00
But I query the left side of the assignment, and it is still unformatted:
? dtWarranties.Rows[i].ItemArray[j]
"1569"
Why won't it "take" the format?




Reply With Quote