1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Formatting Results from DB to show Decimals

Discussion in 'C#' started by Stoty, Feb 8, 2008.

  1. #1
    Hi there,

    I am having an issue with my page displaying the decimal places for whole numbers.
    In the database itself (mySQL), it shows up correctly (ex - 12.0), but when I display the result, it displays as just 12

    here is the code I am using to pull the result:

    <td><%=rsPlayers("Total") %></td>


    Is there anyway I can format that to have it show the decimal value for every number, even if its a whole?

    Thanks in advance for any help.

    *Stoty
     
    Stoty, Feb 8, 2008 IP
  2. mascix

    mascix Active Member

    Messages:
    64
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    93
    #2
    one way:
    <td><%=Convert.ToDouble(rsPlayers("Total")) %></td>

    another way:
    <td><%=Convert.ToDouble(rsPlayers("Total")).ToString("N") %></td>

    in second way you may do any formating if its needed. but before those lines I suggest you to play with your sql select for this. because it can be solved there.

    for more formatting details: http://msdn2.microsoft.com/en-us/library/dwhawy9k.aspx
     
    mascix, Feb 9, 2008 IP