My columns are auto generated for my grid, they are not always the same columns each time it is rendered. I need to check and apply currency formatting if the column is money. This sample works to apply formatting, but it does not specifically check for money.
Does anyone have an idea how I could reliably check for money columns?
Protected Sub gvDataDisplay_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs)
Select Case e.Row.RowType
Case DataControlRowType.DataRow
Dim d As Double = 0.0R
For z As Integer = 0 To e.Row.Cells.Count - 1
Try
d = Convert.ToDouble(e.Row.Cells(z).Text)
If e.Row.Cells(z).Text > 0 Then
e.Row.Cells(z).Text = [String].Format("{0:C2}", d)
Else
e.Row.Cells(z).Text = e.Row.Cells(z).Text
End If
Catch generatedExceptionName As Exception
'e.Row.Cells(z).Text = "0"
End Try
Next
Exit Select
End Select
End Sub
Does anyone have an idea how I could reliably check for money columns?
Protected Sub gvDataDisplay_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs)
Select Case e.Row.RowType
Case DataControlRowType.DataRow
Dim d As Double = 0.0R
For z As Integer = 0 To e.Row.Cells.Count - 1
Try
d = Convert.ToDouble(e.Row.Cells(z).Text)
If e.Row.Cells(z).Text > 0 Then
e.Row.Cells(z).Text = [String].Format("{0:C2}", d)
Else
e.Row.Cells(z).Text = e.Row.Cells(z).Text
End If
Catch generatedExceptionName As Exception
'e.Row.Cells(z).Text = "0"
End Try
Next
Exit Select
End Select
End Sub