S
Scott M.
Ok, this is driving me nuts...
I am using VS.NET 2003 and trying to take an item out of a row in a
loosely-typed dataset and place it in a label as a currency. As it is now,
I am getting my unformatted data values (as decimals) just fine, so I know
there's not a problem with the data retrieval, just the formatting.
I have read that this would work:
lblPrice.Text = prodRow["Price"].ToString("C");
But, I get errors indicating that ToString does not have any overloadable
methods that take any arguments.
I have tried these:
lblTotal.Text = String.Format("{0:c}", prodRow["Total"]);
lblTotal.Text = String.Format("{0:c}", prodRow["Total"].ToString());
lblTotal.Text = String.Format("{0:c}", (decimal) prodRow["Total"]);
and each just returns the number, but not formatted as a currency.
I suspect the problem is that I am getting the data from a loosely-typed
dataset in the first place because I dropped this test code into my page and
it works just fine:
double price = 4.56;
lblTax.Text = String.Format("{0:c}", price);
Here's my original code that does produce my data (just not formatted):
DataRow prodRow = ds.Tables[0].Rows[0];
lblPriceEach.Text = prodRow["RetailPrice"].ToString();
lblPriceAll.Text = prodRow["PriceAll"].ToString();
lblTax.Text = prodRow["Tax"].ToString();
lblTotal.Text = prodRow["Total"].ToString();
I've even tried this (after putting the unformatted data into the label):
lblTotal.Text = String.Format("{0:c}", lblTotal.Text);
But, this just produces the raw number, without any formatting.
What am I not doing or doing wrong?!
Thanks
I am using VS.NET 2003 and trying to take an item out of a row in a
loosely-typed dataset and place it in a label as a currency. As it is now,
I am getting my unformatted data values (as decimals) just fine, so I know
there's not a problem with the data retrieval, just the formatting.
I have read that this would work:
lblPrice.Text = prodRow["Price"].ToString("C");
But, I get errors indicating that ToString does not have any overloadable
methods that take any arguments.
I have tried these:
lblTotal.Text = String.Format("{0:c}", prodRow["Total"]);
lblTotal.Text = String.Format("{0:c}", prodRow["Total"].ToString());
lblTotal.Text = String.Format("{0:c}", (decimal) prodRow["Total"]);
and each just returns the number, but not formatted as a currency.
I suspect the problem is that I am getting the data from a loosely-typed
dataset in the first place because I dropped this test code into my page and
it works just fine:
double price = 4.56;
lblTax.Text = String.Format("{0:c}", price);
Here's my original code that does produce my data (just not formatted):
DataRow prodRow = ds.Tables[0].Rows[0];
lblPriceEach.Text = prodRow["RetailPrice"].ToString();
lblPriceAll.Text = prodRow["PriceAll"].ToString();
lblTax.Text = prodRow["Tax"].ToString();
lblTotal.Text = prodRow["Total"].ToString();
I've even tried this (after putting the unformatted data into the label):
lblTotal.Text = String.Format("{0:c}", lblTotal.Text);
But, this just produces the raw number, without any formatting.
What am I not doing or doing wrong?!
Thanks