473,407 Members | 2,312 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,407 software developers and data experts.

combining datatypes in bound column

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??

Apr 10 '06 #1
5 1216
hook into ItemCreated event for the grid and then override the text in the
cell directly.

<dr****@canoemail.com> wrote in message
news:11**********************@i40g2000cwc.googlegr oups.com...
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??
Apr 10 '06 #2
Use a TemplateField instead of a BoundField.

"dr****@canoemail.com" wrote:
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??

Apr 10 '06 #3
I would change the select query.....

like,

SELECT (case Price when 0 then NULL else Price end) as Price from Table

Bruno

<dr****@canoemail.com> wrote in message
news:11**********************@i40g2000cwc.googlegr oups.com...
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??
Apr 10 '06 #4
Why would you want your data access layer be driven by UI? So if tomorow
client changes requirement, would you keep playing with your queries?
"Bruno Piovan" <brunopiovan AT gmail DOT COM - NO SPAM> wrote in message
news:uG**************@TK2MSFTNGP04.phx.gbl...
I would change the select query.....

like,

SELECT (case Price when 0 then NULL else Price end) as Price from Table

Bruno

<dr****@canoemail.com> wrote in message
news:11**********************@i40g2000cwc.googlegr oups.com...
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??

Apr 10 '06 #5
I work this way....

much faster go and change a query than recompile code.....

I aways worked like this and never had problems..

Of course I use only stored procedures instead of tsql directly.....

Bruno

"Winista" <na*********@hotmail.com> wrote in message
news:uA**************@TK2MSFTNGP03.phx.gbl...
Why would you want your data access layer be driven by UI? So if tomorow
client changes requirement, would you keep playing with your queries?
"Bruno Piovan" <brunopiovan AT gmail DOT COM - NO SPAM> wrote in message
news:uG**************@TK2MSFTNGP04.phx.gbl...
I would change the select query.....

like,

SELECT (case Price when 0 then NULL else Price end) as Price from Table

Bruno

<dr****@canoemail.com> wrote in message
news:11**********************@i40g2000cwc.googlegr oups.com...
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??


Apr 10 '06 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Jan Agermose | last post by:
Im writing information into an existing excel document using a connection string like: strConn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + Filename + ";Extended Properties=\"Excel...
3
by: J. Muenchbourg | last post by:
while inserting new records into SQL, i'm using the folloinwg sqlstatement> Dim MySQL as string = "Insert into roster (pname, pnotes, thedate) values (@pname, @pnotes, @thedate)" the sql...
3
by: Cindi Simonson | last post by:
Hi, I have a form with a combo box containing 4 columns of data. The form also contains 3 print buttons where the goal is to open 3 different reports according to the value in one of the...
3
by: Glenn Sullivan | last post by:
I need to acquire the list of all column names and datatypes from a table through the JDBC interface using an sql command. What I want is available in "psql" with the "\d tablename" command, but I...
2
by: Mark Harrison | last post by:
How can I combine these two queries? # select viewerid,count(*) from viewer_movies group by viewerid order by viewerid; viewerid | count ----------+-------- 22964835 | 3055 22964836 | ...
5
by: Andy Kent | last post by:
What's the syntax for combining INTO and UNION clauses? What I want to do is: SELECT blah INTO newtable FROM oldtable1 WHERE <conditions> UNION SELECT blah
1
by: Henri Schomäcker | last post by:
Hi folks, what I need is a kind of 2D-Array which should, in the end, represent a typical html-table and which should be sortable by column. I thought of an implementation, where an vector...
3
by: pinney.colton | last post by:
I have a SQL 2005 database that's created by a survey data collection system. Users of this system are fairly non-technical and have little to no conscious control over the datatypes. As a...
0
by: Clare CAVS | last post by:
I have a table with a lookup column referring to another table . tblRooms has two fields, (Autonumber), and . The column I want to display is the RoomName column. If I have Bound Column = 1,...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.