Link to home
Start Free TrialLog in
Avatar of DeniseGoodheart
DeniseGoodheart

asked on

GridView - Format Cell To Remove Trailing Zeros From Decimal Value

Hi,

I’m using ASP.NET 2 with VB and SQL Server.  I’m using the GridView control.  The 2nd column on my grid contains decimal values. The GridView displays it as 15.3300000000000000.  How do I format the 2nd column to remove the trailing zeros?  I would like it formatted as 15.33?

My code is as follows:

Private Sub LoadSourceReports()

        sCon = oCon.SqlConString
        Dim Con As SqlConnection = New SqlConnection(sCon)

        sSql = "Select [Source of Reports],[%],Number from vwSourceReports_2"

        Dim da As New SqlClient.SqlDataAdapter(sSql, sCon)
        Dim ds As New DataSet
        ds = New DataSet()
        da.Fill(ds, "vwSourceReports_2")
        Me.grdSourceReports.DataSource = ds
        Me.grdSourceReports.DataBind()

    End Sub

Thanks,
Denise

SOLUTION
Avatar of bele04
bele04

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of DeniseGoodheart
DeniseGoodheart

ASKER

Hi Skumar,

Thanks for your suggestion.  I tried {0:F2} and it did not work.  Any more suggestions?

Thanks,
Denise

Hi All,

Both of your answers were very helpful.  After I set the HtmlEncode property of that column to “False", it worked!  

Many Thanks,
Denise