• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 937
  • Last Modified:

Suppress zero values in a databound field in a gridview

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?
0
CantonMarko
Asked:
CantonMarko
  • 2
1 Solution
 
srikanthreddyn143Commented:
If you are getting from a query, then you can make like

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

Or

You can loop through

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


Above is a test code. I didnt test it.
0
 
srikanthreddyn143Commented:
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 = " "
}
}
0

Featured Post

NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now