Formatting is not being done

Discussion in 'ASP .Net Datagrid Control' started by Evan Camilleri, Apr 13, 2006.

  1. 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
     
    Evan Camilleri, Apr 13, 2006
    #1
    1. Advertising

  2. 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
    >
     
    Bruno Alexandre, Apr 18, 2006
    #2
    1. Advertising

  3. Evan Camilleri

    Vear Guest

    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
    >
    >
    >
     
    Vear, Apr 19, 2006
    #3
  4. 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
     
    Richard Anacker, Apr 19, 2006
    #4
  5. 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
     
    Richard Anacker, Apr 19, 2006
    #5
  6. or

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


    --


    Thank you in Advance.

    Bruno Alexandre
    (a Portuguese in Denmark)

    "Richard Anacker" <> escreveu na mensagem
    news:mnk68hrv4arx$-anacker.de...
    > 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
     
    Bruno Alexandre, Apr 19, 2006
    #6
  7. Am 19.04.2006 schrieb Bruno Alexandre:

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


    Ah - thx!

    richie
     
    Richard Anacker, Apr 19, 2006
    #7
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?TWFyayBQYXJ0ZXI=?=

    Form still being submitted despite being invalid

    =?Utf-8?B?TWFyayBQYXJ0ZXI=?=, Jul 25, 2005, in forum: ASP .Net
    Replies:
    4
    Views:
    621
  2. Younger Dryas
    Replies:
    2
    Views:
    2,453
    Sharad Kala
    Feb 15, 2004
  3. ManicQin
    Replies:
    2
    Views:
    287
    ManicQin
    Jul 23, 2008
  4. Sumitava Mukherjee
    Replies:
    4
    Views:
    287
    Tim Roberts
    Oct 21, 2008
  5. Zhidian Du
    Replies:
    0
    Views:
    166
    Zhidian Du
    Feb 21, 2004
Loading...

Share This Page