Convert to double

Discussion in 'ASP .Net Web Controls' started by ruca, Feb 23, 2004.

  1. ruca

    ruca Guest

    Hi people,

    I can I format this expression into a double of two places:

    <ItemTemplate>
    <asp:Label runat="server" text='<%#
    ((DataBinder.Eval(Container,"DataItem.Duracao"))*24).ToString()%>' />
    </ItemTemplate>


    --

    Thank's (if you try to help me)
    Hope this help you (if I try to help you)
    ruca
    ruca, Feb 23, 2004
    #1
    1. Advertising

  2. Hi, ruca,

    Have a look at:

    http://msdn.microsoft.com/library/en-us/cpguide/html/cpconcustomnumericformatstrings.asp

    For your case I think

    ..ToString("#####.00")

    should work.

    Possible problems:

    1. (I'm not sure if it is a problem in VB.NET, but it is in C#) When
    multiplying by 24 (this literal is treated as System.Int32 in C#) the result
    will be System.Int32. Apart from that, I can only guess what will be the
    type of DataBinder.Eval(Container,"DataItem.Duracao") on the late binding in
    VB.NET. In C# it is object (no late binding) and you have to parse it (as I
    don't think the cast will work) and you have to add the appropriate suffix
    for the literal to be treated as the required type in order to get the
    result of the multiplication to be the required type, i.e. System.Decimal.

    2. It is way more performant to make this calculation inside your sql or at
    least in the page class before the databinding thus having the data ready
    for the presentation layer to only display it to the client.

    Hope this helps
    Martin
    "ruca" <> wrote in message
    news:uAmlhGf#...
    > Hi people,
    >
    > I can I format this expression into a double of two places:
    >
    > <ItemTemplate>
    > <asp:Label runat="server" text='<%#
    > ((DataBinder.Eval(Container,"DataItem.Duracao"))*24).ToString()%>' />
    > </ItemTemplate>
    >
    >
    > --
    >
    > Thank's (if you try to help me)
    > Hope this help you (if I try to help you)
    > ruca
    >
    >
    Martin Dechev, Feb 23, 2004
    #2
    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. Web learner

    from List <double> to double[]

    Web learner, Apr 25, 2006, in forum: ASP .Net
    Replies:
    3
    Views:
    466
  2. sb
    Replies:
    4
    Views:
    297
    Alberto Barbati
    Feb 19, 2004
  3. da Vinci
    Replies:
    5
    Views:
    8,707
    da Vinci
    Jul 31, 2004
  4. Sydex
    Replies:
    12
    Views:
    6,454
    Victor Bazarov
    Feb 17, 2005
  5. Heiko Vogel
    Replies:
    3
    Views:
    548
    Method Man
    Sep 14, 2004
Loading...

Share This Page