all groups > asp.net webcontrols > july 2003 >
You're in the

asp.net webcontrols

group:

Format Currency In DataGrid



Format Currency In DataGrid Derek
7/11/2003 2:29:15 PM
asp.net webcontrols: Hi,

I am creating several datagrids via code on a page so I
do not have any Bound columns and I don't want any.
Problem is I need to format the last column as currency.
Anyone know how to do this without a BoundColumn? Is it
possible to get SQL server to return the data formatted
as currency? If so, how.


Thanks,

Re: Format Currency In DataGrid Alvin Bruney
7/12/2003 11:13:27 PM
in your itemdatabound do something like this
NumberFormatInfo nfi = new CultureInfo( "en-US", false ).NumberFormat;

nfi.CurrencyDecimalDigits = 2;

e.item.cells[e.item.cells.count - 1].text =
e.item.cells[e.item.cells.count - 1].text.toString("C",nfi);

i haven't tested this though.

[quoted text, click to view]

AddThis Social Bookmark Button