Suppress zero values in a databound field in a gridview

Posted on 2009-04-30
Last Modified: 2013-12-17
Can anyone show me a way to make any cell in my gridview that has a zero value show a blank instead of the zero?
Question by:CantonMarko
    LVL 11

    Expert Comment

    If you are getting from a query, then you can make like

    select Col1,case when col2 = 0 then ' ' else end, Col3 from tb1


    You can loop through

    For Each Row in GrdView.Rows
    If oRow.Cells("Col2").Value = 0 Then
    oRow.Cells("Col2").Value = " "
    End iF

    Above is a test code. I didnt test it.
    LVL 11

    Accepted Solution

    oops my bad I wrote it in VB.Net  for the code.Like this

    For Each (GridRow Row in GrdView.Rows)
    If (oRow.Cells("Col2").Value == 0)
    oRow.Cells("Col2").Value = " "

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    Welcome my friends to the second instalment and follow-up to our Minify and Concatenate Your Scripts and Stylesheets (…
    International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
    Hi everyone! This is Experts Exchange customer support.  This quick video will show you how to change your primary email address.  If you have any questions, then please Write a Comment below!
    This video discusses moving either the default database or any database to a new volume.

    737 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    20 Experts available now in Live!

    Get 1:1 Help Now