D
drdave
Hi,
In a bound column I have currency datatypes, but the client does not
like $ 0.00 and wants to show a blank instead.. I'm trying to use an if
statement to write out string.empty but it doesn't want to allow the
different datatype..
The currency amounts are stored as number in the db...
How can I accomplish this?
*** Code: ****
Public Sub CreateGrid()
'*** Make the year coming from the dropdown into a
datetime
Dim stryearval As String
stryearval = "01/01/" & ddlYears.SelectedItem.Value
'declare a new datagrid and set properties
Dim dgSearchResults As New DataGrid()
dgSearchResults.BorderWidth = Unit.Pixel(2)
dgSearchResults.CellPadding = 10
dgSearchResults.GridLines = GridLines.Both
dgSearchResults.ShowHeader = True
dgSearchResults.AutoGenerateColumns = False
dgSearchResults.HeaderStyle.Font.Bold = True
'add bound columns to the datagrid
Dim ProvCol As BoundColumn = New BoundColumn()
ProvCol.DataField = "provincename"
Dim EffDateCol As BoundColumn = New BoundColumn()
EffDateCol.DataField = "effective_date"
EffDateCol.DataFormatString = "{0:d}"
********************************************* This throws ERROR
****************************
********* System.FormatException: Input string was not in a correct
format ***************
Dim MinWageCol As BoundColumn = New BoundColumn()
MinWageCol.DataField = "minimum_wage_amount"
If MinWageCol.DataField = 0
MinWageCol.DataField = string.Empty
Else
MinWageCol.DataFormatString = "{0:c}"
End If
************************************************ Rest is good
**************************
MinWageCol.ItemStyle.HorizontalAlign = HorizontalAlign.Center
Dim VarCol As BoundColumn = New BoundColumn()
'Set Headers
If (Session("Language") Is "en-CA") Then
ProvCol.HeaderText = "Province"
EffDateCol.HeaderText = "Effective Date"
MinWageCol.HeaderText = "Minimum Wage"
VarCol.HeaderText = "Condition"
VarCol.DataField = "english_text"
Else
ProvCol.HeaderText = "Administration"
EffDateCol.HeaderText = "Date d'entrée en vigueur"
MinWageCol.HeaderText = "Salaire minimum"
VarCol.HeaderText = "Remarque"
VarCol.DataField = "french_text"
End If
** Code End ***
Am I missing some syntax??
In a bound column I have currency datatypes, but the client does not
like $ 0.00 and wants to show a blank instead.. I'm trying to use an if
statement to write out string.empty but it doesn't want to allow the
different datatype..
The currency amounts are stored as number in the db...
How can I accomplish this?
*** Code: ****
Public Sub CreateGrid()
'*** Make the year coming from the dropdown into a
datetime
Dim stryearval As String
stryearval = "01/01/" & ddlYears.SelectedItem.Value
'declare a new datagrid and set properties
Dim dgSearchResults As New DataGrid()
dgSearchResults.BorderWidth = Unit.Pixel(2)
dgSearchResults.CellPadding = 10
dgSearchResults.GridLines = GridLines.Both
dgSearchResults.ShowHeader = True
dgSearchResults.AutoGenerateColumns = False
dgSearchResults.HeaderStyle.Font.Bold = True
'add bound columns to the datagrid
Dim ProvCol As BoundColumn = New BoundColumn()
ProvCol.DataField = "provincename"
Dim EffDateCol As BoundColumn = New BoundColumn()
EffDateCol.DataField = "effective_date"
EffDateCol.DataFormatString = "{0:d}"
********************************************* This throws ERROR
****************************
********* System.FormatException: Input string was not in a correct
format ***************
Dim MinWageCol As BoundColumn = New BoundColumn()
MinWageCol.DataField = "minimum_wage_amount"
If MinWageCol.DataField = 0
MinWageCol.DataField = string.Empty
Else
MinWageCol.DataFormatString = "{0:c}"
End If
************************************************ Rest is good
**************************
MinWageCol.ItemStyle.HorizontalAlign = HorizontalAlign.Center
Dim VarCol As BoundColumn = New BoundColumn()
'Set Headers
If (Session("Language") Is "en-CA") Then
ProvCol.HeaderText = "Province"
EffDateCol.HeaderText = "Effective Date"
MinWageCol.HeaderText = "Minimum Wage"
VarCol.HeaderText = "Condition"
VarCol.DataField = "english_text"
Else
ProvCol.HeaderText = "Administration"
EffDateCol.HeaderText = "Date d'entrée en vigueur"
MinWageCol.HeaderText = "Salaire minimum"
VarCol.HeaderText = "Remarque"
VarCol.DataField = "french_text"
End If
** Code End ***
Am I missing some syntax??