HOW TO ROUND DECIMAL VALUE IN GRIDVIEW

Jeet Verma

Total Post:110

Points:776
Posted by  Jeet Verma
 1264  View(s)
Ratings:
Rate this:

I am trying to round the result of my code to 2 decimal places, but ROUND isn't working. Any help? Thanks!

<asp:SqlDataSource ID="SqlDataSource1"runat="server" 
     ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
     SelectCommand="SELECT [Id], [attempts], [total], (round(attempts / total,(2))) AS [Percentage] FROM [Game]">
</asp:SqlDataSource>
  1. Sumit Kesarwani

    Post:378

    Points:2694
    Re: how to round decimal value in Gridview

    Hi Jeet, 


    try this:

    CAST(ROUND(attempts/total,2) as DECIMAL(12,2))
    OR
    attempts/CAST(total as DECIMAL(12,2))
    OR
    CAST(attempts AS DECIMAL(12,2))/total

      Modified On Apr-06-2018 11:41:32 PM

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!