Formatting a gridview column of numbers as currency
Back to the tutorials list
Introduction
In many situations, your database may contain numbers representing money, and
you would like to show in, for example, a gridview, those number as currency,
like $4,235.43 -- as dollars and cents.
Setting a
currency format for gridview data
With VWD, open your test website (it was named MyTutorialsWebsite), and then
open the page called "DatabaseResultsPage.aspx". That page should display the
database results you previously generated in a gridview, and the records include
a Payment column that shows numbers. To convert those numbers to a currency
format:
1. In the GridView, click the little expander arrow on the upper right, select Edit
Columns, and highlight the Payment column.
2. In the Behavior section set htmlencode to False.
3. In the Data section, for the DataFormatString type: {0:C}
4. Click OK, save, Preview in Browser.
That should result in the data showing up as currency, like $433.50