How to show monetary values in a DataGrid

  • Thread starter Henrique Berenguel
  • Start date
H

Henrique Berenguel

Hello folks. I have a DataGrid in a Web Form. I´d like to show numeric
columns in Money format US$ 10,000.98. However, when I fill the DataGrid
from a SqlCommand, it fill in the DataGrid like this: 1000098. How do I do
that?

Thanks
 
N

Naveen K Kohli

Specify the DataFormatString for your bound column..

<asp:BoundColumn HeaderText="MoneyMoney" DataField="Price" DataFormatString
= {0:c} />
 
H

Henrique Berenguel

The problem is that I´m using the option:

'Create columns automatically at run time' in the Property Builder of my
DataGrid.

Then I don´t have bound columns in the html, that´s the problem...

Look the code:

<asp:datagrid id="DataGrid1" runat="server" BackColor="White"
Width="692px" BorderColor="#999999" PageSize="3" AllowPaging="True"
BorderStyle="None" BorderWidth="1px" CellPadding="3" GridLines="Vertical"
Height="94px">
<SelectedItemStyle Font-Bold="True" ForeColor="White"
BackColor="#008A8C"></SelectedItemStyle>
<AlternatingItemStyle BackColor="Gainsboro"></AlternatingItemStyle>
<ItemStyle ForeColor="Black" BackColor="#EEEEEE"></ItemStyle>
<HeaderStyle Font-Bold="True" ForeColor="White"
BackColor="#000084"></HeaderStyle>
<FooterStyle ForeColor="Black" BackColor="#CCCCCC"></FooterStyle>
<Columns><asp:ButtonColumn Text="Selecionar"
CommandName="Select"></asp:ButtonColumn></Columns>
<PagerStyle HorizontalAlign="Center" ForeColor="Black" BackColor="#999999"
Mode="NumericPages"></PagerStyle>
</asp:datagrid>

Is there an other way to do that?

Or will I have to reprogram everything to recreate the browser with bounds
columns?

Thanks in advance
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top