How to show monetary values in a DataGrid

  • Thread starter Thread starter Henrique Berenguel
  • Start date 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
 
Specify the DataFormatString for your bound column..

<asp:BoundColumn HeaderText="MoneyMoney" DataField="Price" DataFormatString
= {0:c} />
 
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
 
Back
Top