format Boundcolumn as Percentage

Discussion in 'ASP .Net Datagrid Control' started by RobbRoss, Jun 17, 2004.

  1. RobbRoss

    RobbRoss Guest

    I have a datagrid with Boundcolumns. I have a number in the db that represents a percentage. I want the datagrid column to output the percentage and not the number. For example instead of 0.82 I want 82%.
     
    RobbRoss, Jun 17, 2004
    #1
    1. Advertising

  2. You can use a custom format with "p".

    <Columns>
    <asp:BoundColumn DataField="Percentvalue" ReadOnly="True"
    HeaderText="Percentvalue" DataFormatString="{0:p}"></asp:BoundColumn>
    </Columns>

    See also here:

    http://www.datawebcontrols.com/faqs/CustomizingAppearance/FormatNumericData.shtml

    Ken
    Microsoft MVP [ASP.NET]

    "RobbRoss" <> wrote in message
    news:...
    >I have a datagrid with Boundcolumns. I have a number in the db that
    >represents a percentage. I want the datagrid column to output the
    >percentage and not the number. For example instead of 0.82 I want 82%.
     
    Ken Cox [Microsoft MVP], Jun 17, 2004
    #2
    1. Advertising

  3. RobbRoss

    Jos Guest

    "RobbRoss" <> wrote in message
    news:...
    > I have a datagrid with Boundcolumns. I have a number in the db that

    represents a percentage. I want the datagrid column to output the
    percentage and not the number. For example instead of 0.82 I want 82%.

    Set the DataFormatString property for the BoundColumn to {0:##.00%}
    like this:
    <asp:BoundColumn DataField="MyNumberField" DataFormatString="{0:##.00%}">

    More formatting options here:
    http://msdn.microsoft.com/library/en-us/cpguide/html/cpconnumericformatstrings.asp

    Jos
     
    Jos, Jun 17, 2004
    #3
    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. Chris

    html image percentage issue

    Chris, Jul 23, 2003, in forum: ASP .Net
    Replies:
    7
    Views:
    2,291
    John Saunders
    Jul 24, 2003
  2. fake ID
    Replies:
    1
    Views:
    14,459
  3. fake ID
    Replies:
    0
    Views:
    591
    fake ID
    Feb 10, 2006
  4. mesut
    Replies:
    0
    Views:
    574
    mesut
    Jun 29, 2007
  5. Prasad Dannani

    Format Double Values using BoundColumn.DataFormatString

    Prasad Dannani, Jun 25, 2005, in forum: ASP .Net Datagrid Control
    Replies:
    1
    Views:
    482
    Elton Wang
    Jun 27, 2005
Loading...

Share This Page