Formatting is not being done

E

Evan Camilleri

I have the following:

<asp:BoundColumn DataField="Buy0" HeaderText="Buy"
DataFormatString="{0:N2}">
<HeaderStyle Width="50px"></HeaderStyle>
<ItemStyle Wrap="False"></ItemStyle>
</asp:BoundColumn>



But:

Formatting is not being done. I have 6 decimal places and not 2
Size (Width) if being ignored
 
B

Bruno Alexandre

change that into this: (example is for GridView under ASP.NET 2.0)

<asp:TemplateField HeaderText="Buy" >
<ItemTemplate>
<asp:Label id="lblBuy" Runat="Server"
Text='<%# FormatNumber( Eval("Buy0", {0:n2}) ) %>'/>
</ItemTemplate>
</asp:TemplateField>


--


Thank you in Advance.

Bruno Alexandre
(a Portuguese in Denmark)
 
V

Vear

In the columns properties in the grid you have to set HTMLEncode to false.
Then formatting will work.

Vear
 
R

Richard Anacker

Am 13.04.2006 schrieb Evan Camilleri:
I have the following:
[...]

Sorry, that I just enter this thread here to show my problem - which
is a different one (I believe).

I'm pretty new to VS2005EXPR and WD2005EXPR and just started to learn
from D.J. Reilly's book about WebForm-programing.

There he writes, that it is possible to chance the format of a
DateTime-Cols in a DataGrid by just entering a DataFormatString -
which I did but it doesn't work.

The markup is then:

<Columns>
<asp:BoundField DataField="Datum"
DataFormatString="{0:ddd, dd.MM.yyyy}" HeaderText="Datum"
SortExpression="Datum" />
[...]

but the browser allways shows 18.04.2006 00:00:00 (for example)

Did I understand something wrong, was his information false or does
anything else went the wrong way?

thanks for Information in advance

richie
 
R

Richard Anacker

Am 19.04.2006 schrieb Richard Anacker:
<Columns>
<asp:BoundField DataField="Datum"
DataFormatString="{0:ddd, dd.MM.yyyy}" HeaderText="Datum"
SortExpression="Datum" />

Ok, got it.

After entering a DataFormatString in design-view and after that
changing the field to templateField the markup showes

<ItemTemplate>
<asp:Label ID="Label1" runat="server" Text='<%# Bind("Datum",
"{0:ddd, dd.MM.yyyy}") %>'></asp:Label>
</ItemTemplate>

and this works now.

richie
 
B

Bruno Alexandre

or

Text='<%# FormatDateTime( Bind("Datum"), 1) %>'


--


Thank you in Advance.

Bruno Alexandre
(a Portuguese in Denmark)
 

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

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,016
Latest member
TatianaCha

Latest Threads

Top