rikket
rikket

Reputation: 2407

Display $ in gridview Price Column

<asp:BoundField DataField="ProductPrice" HeaderText="Price" />

How can I display a dollor sign before each record in the above column for every row?

Upvotes: 0

Views: 3792

Answers (2)

phnkha
phnkha

Reputation: 7882

Use TemplateField instead of BoundField, you can format it like anything you want

<asp:TemplateField HeaderText="Price">
       <ItemTemplate>
             $<%# Eval("ProductPrice")%>
       </ItemTemplate>
</asp:TemplateField>

Upvotes: 0

Agustin Meriles
Agustin Meriles

Reputation: 4854

You can format your data value as Currency by using DataFormatString

<asp:BoundField DataField="ProductPrice" HeaderText="Price" DataFormatString="{0:C}" />

if the culture is setted to a country who has a dollar currency, it will work fine.

Upvotes: 4

Related Questions