Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Datagrid Control > Formatting is not being done

Reply
Thread Tools

Formatting is not being done

 
 
Evan Camilleri
Guest
Posts: n/a
 
      04-13-2006

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


 
Reply With Quote
 
 
 
 
Bruno Alexandre
Guest
Posts: n/a
 
      04-18-2006
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)

"Evan Camilleri" <> escreveu na mensagem
news:%...
>
> 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
>



 
Reply With Quote
 
 
 
 
Vear
Guest
Posts: n/a
 
      04-19-2006
In the columns properties in the grid you have to set HTMLEncode to false.
Then formatting will work.

Vear

"Evan Camilleri" wrote:

>
> 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
>
>
>

 
Reply With Quote
 
Richard Anacker
Guest
Posts: n/a
 
      04-19-2006
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
 
Reply With Quote
 
Richard Anacker
Guest
Posts: n/a
 
      04-19-2006
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
 
Reply With Quote
 
Bruno Alexandre
Guest
Posts: n/a
 
      04-19-2006
or

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


--


Thank you in Advance.

Bruno Alexandre
(a Portuguese in Denmark)

"Richard Anacker" <news-2006-> escreveu na mensagem
news:mnk68hrv4arx$....
> 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



 
Reply With Quote
 
Richard Anacker
Guest
Posts: n/a
 
      04-19-2006
Am 19.04.2006 schrieb Bruno Alexandre:

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


Ah - thx!

richie
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Is there any implementation work being done for the new STD? ManicQin C++ 2 07-23-2008 02:12 PM
I asked before and was told it could not be done, well its Done...?? Karen Parker NZ Computing 32 08-27-2004 07:21 AM
I asked before and was told it could not be done, well its Done...?? Karen Parker NZ Computing 7 08-26-2004 02:25 AM
How to let browsers be done when parent is done and not wait for childrn's finishing in CGI Zhidian Du Perl Misc 0 02-21-2004 07:01 PM
How can I log Instant Messaging being done on my computer? Younger Dryas C++ 2 02-15-2004 11:40 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57