473,602 Members | 2,811 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.Select edItem.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 .AutoGenerateCo lumns = False
dgSearchResults .HeaderStyle.Fo nt.Bold = True

'add bound columns to the datagrid
Dim ProvCol As BoundColumn = New BoundColumn()
ProvCol.DataFie ld = "provincena me"
Dim EffDateCol As BoundColumn = New BoundColumn()
EffDateCol.Data Field = "effective_date "
EffDateCol.Data FormatString = "{0:d}"

*************** *************** *************** This throws ERROR
*************** *************
********* System.FormatEx ception: Input string was not in a correct
format ***************

Dim MinWageCol As BoundColumn = New BoundColumn()
MinWageCol.Data Field = "minimum_wage_a mount"
If MinWageCol.Data Field = 0
MinWageCol.Data Field = string.Empty
Else
MinWageCol.Data FormatString = "{0:c}"
End If
*************** *************** *************** *** Rest is good
*************** ***********
MinWageCol.Item Style.Horizonta lAlign = HorizontalAlign .Center
Dim VarCol As BoundColumn = New BoundColumn()
'Set Headers
If (Session("Langu age") Is "en-CA") Then
ProvCol.HeaderT ext = "Province"
EffDateCol.Head erText = "Effective Date"
MinWageCol.Head erText = "Minimum Wage"
VarCol.HeaderTe xt = "Condition"
VarCol.DataFiel d = "english_te xt"
Else
ProvCol.HeaderT ext = "Administration "
EffDateCol.Head erText = "Date d'entrée en vigueur"
MinWageCol.Head erText = "Salaire minimum"
VarCol.HeaderTe xt = "Remarque"
VarCol.DataFiel d = "french_tex t"
End If

** Code End ***

Am I missing some syntax??

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

<dr****@canoema il.com> wrote in message
news:11******** **************@ i40g2000cwc.goo glegroups.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.Select edItem.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 .AutoGenerateCo lumns = False
dgSearchResults .HeaderStyle.Fo nt.Bold = True

'add bound columns to the datagrid
Dim ProvCol As BoundColumn = New BoundColumn()
ProvCol.DataFie ld = "provincena me"
Dim EffDateCol As BoundColumn = New BoundColumn()
EffDateCol.Data Field = "effective_date "
EffDateCol.Data FormatString = "{0:d}"

*************** *************** *************** This throws ERROR
*************** *************
********* System.FormatEx ception: Input string was not in a correct
format ***************

Dim MinWageCol As BoundColumn = New BoundColumn()
MinWageCol.Data Field = "minimum_wage_a mount"
If MinWageCol.Data Field = 0
MinWageCol.Data Field = string.Empty
Else
MinWageCol.Data FormatString = "{0:c}"
End If
*************** *************** *************** *** Rest is good
*************** ***********
MinWageCol.Item Style.Horizonta lAlign = HorizontalAlign .Center
Dim VarCol As BoundColumn = New BoundColumn()
'Set Headers
If (Session("Langu age") Is "en-CA") Then
ProvCol.HeaderT ext = "Province"
EffDateCol.Head erText = "Effective Date"
MinWageCol.Head erText = "Minimum Wage"
VarCol.HeaderTe xt = "Condition"
VarCol.DataFiel d = "english_te xt"
Else
ProvCol.HeaderT ext = "Administration "
EffDateCol.Head erText = "Date d'entrée en vigueur"
MinWageCol.Head erText = "Salaire minimum"
VarCol.HeaderTe xt = "Remarque"
VarCol.DataFiel d = "french_tex t"
End If

** Code End ***

Am I missing some syntax??
Apr 10 '06 #2
Use a TemplateField instead of a BoundField.

"dr****@canoema il.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.Select edItem.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 .AutoGenerateCo lumns = False
dgSearchResults .HeaderStyle.Fo nt.Bold = True

'add bound columns to the datagrid
Dim ProvCol As BoundColumn = New BoundColumn()
ProvCol.DataFie ld = "provincena me"
Dim EffDateCol As BoundColumn = New BoundColumn()
EffDateCol.Data Field = "effective_date "
EffDateCol.Data FormatString = "{0:d}"

*************** *************** *************** This throws ERROR
*************** *************
********* System.FormatEx ception: Input string was not in a correct
format ***************

Dim MinWageCol As BoundColumn = New BoundColumn()
MinWageCol.Data Field = "minimum_wage_a mount"
If MinWageCol.Data Field = 0
MinWageCol.Data Field = string.Empty
Else
MinWageCol.Data FormatString = "{0:c}"
End If
*************** *************** *************** *** Rest is good
*************** ***********
MinWageCol.Item Style.Horizonta lAlign = HorizontalAlign .Center
Dim VarCol As BoundColumn = New BoundColumn()
'Set Headers
If (Session("Langu age") Is "en-CA") Then
ProvCol.HeaderT ext = "Province"
EffDateCol.Head erText = "Effective Date"
MinWageCol.Head erText = "Minimum Wage"
VarCol.HeaderTe xt = "Condition"
VarCol.DataFiel d = "english_te xt"
Else
ProvCol.HeaderT ext = "Administration "
EffDateCol.Head erText = "Date d'entrée en vigueur"
MinWageCol.Head erText = "Salaire minimum"
VarCol.HeaderTe xt = "Remarque"
VarCol.DataFiel d = "french_tex t"
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****@canoema il.com> wrote in message
news:11******** **************@ i40g2000cwc.goo glegroups.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.Select edItem.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 .AutoGenerateCo lumns = False
dgSearchResults .HeaderStyle.Fo nt.Bold = True

'add bound columns to the datagrid
Dim ProvCol As BoundColumn = New BoundColumn()
ProvCol.DataFie ld = "provincena me"
Dim EffDateCol As BoundColumn = New BoundColumn()
EffDateCol.Data Field = "effective_date "
EffDateCol.Data FormatString = "{0:d}"

*************** *************** *************** This throws ERROR
*************** *************
********* System.FormatEx ception: Input string was not in a correct
format ***************

Dim MinWageCol As BoundColumn = New BoundColumn()
MinWageCol.Data Field = "minimum_wage_a mount"
If MinWageCol.Data Field = 0
MinWageCol.Data Field = string.Empty
Else
MinWageCol.Data FormatString = "{0:c}"
End If
*************** *************** *************** *** Rest is good
*************** ***********
MinWageCol.Item Style.Horizonta lAlign = HorizontalAlign .Center
Dim VarCol As BoundColumn = New BoundColumn()
'Set Headers
If (Session("Langu age") Is "en-CA") Then
ProvCol.HeaderT ext = "Province"
EffDateCol.Head erText = "Effective Date"
MinWageCol.Head erText = "Minimum Wage"
VarCol.HeaderTe xt = "Condition"
VarCol.DataFiel d = "english_te xt"
Else
ProvCol.HeaderT ext = "Administration "
EffDateCol.Head erText = "Date d'entrée en vigueur"
MinWageCol.Head erText = "Salaire minimum"
VarCol.HeaderTe xt = "Remarque"
VarCol.DataFiel d = "french_tex t"
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******** ******@TK2MSFTN GP04.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****@canoema il.com> wrote in message
news:11******** **************@ i40g2000cwc.goo glegroups.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.Select edItem.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 .AutoGenerateCo lumns = False
dgSearchResults .HeaderStyle.Fo nt.Bold = True

'add bound columns to the datagrid
Dim ProvCol As BoundColumn = New BoundColumn()
ProvCol.DataFie ld = "provincena me"
Dim EffDateCol As BoundColumn = New BoundColumn()
EffDateCol.Data Field = "effective_date "
EffDateCol.Data FormatString = "{0:d}"

*************** *************** *************** This throws ERROR
*************** *************
********* System.FormatEx ception: Input string was not in a correct
format ***************

Dim MinWageCol As BoundColumn = New BoundColumn()
MinWageCol.Data Field = "minimum_wage_a mount"
If MinWageCol.Data Field = 0
MinWageCol.Data Field = string.Empty
Else
MinWageCol.Data FormatString = "{0:c}"
End If
*************** *************** *************** *** Rest is good
*************** ***********
MinWageCol.Item Style.Horizonta lAlign = HorizontalAlign .Center
Dim VarCol As BoundColumn = New BoundColumn()
'Set Headers
If (Session("Langu age") Is "en-CA") Then
ProvCol.HeaderT ext = "Province"
EffDateCol.Head erText = "Effective Date"
MinWageCol.Head erText = "Minimum Wage"
VarCol.HeaderTe xt = "Condition"
VarCol.DataFiel d = "english_te xt"
Else
ProvCol.HeaderT ext = "Administration "
EffDateCol.Head erText = "Date d'entrée en vigueur"
MinWageCol.Head erText = "Salaire minimum"
VarCol.HeaderTe xt = "Remarque"
VarCol.DataFiel d = "french_tex t"
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*********@ho tmail.com> wrote in message
news:uA******** ******@TK2MSFTN GP03.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******** ******@TK2MSFTN GP04.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****@canoema il.com> wrote in message
news:11******** **************@ i40g2000cwc.goo glegroups.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.Select edItem.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 .AutoGenerateCo lumns = False
dgSearchResults .HeaderStyle.Fo nt.Bold = True

'add bound columns to the datagrid
Dim ProvCol As BoundColumn = New BoundColumn()
ProvCol.DataFie ld = "provincena me"
Dim EffDateCol As BoundColumn = New BoundColumn()
EffDateCol.Data Field = "effective_date "
EffDateCol.Data FormatString = "{0:d}"

*************** *************** *************** This throws ERROR
*************** *************
********* System.FormatEx ception: Input string was not in a correct
format ***************

Dim MinWageCol As BoundColumn = New BoundColumn()
MinWageCol.Data Field = "minimum_wage_a mount"
If MinWageCol.Data Field = 0
MinWageCol.Data Field = string.Empty
Else
MinWageCol.Data FormatString = "{0:c}"
End If
*************** *************** *************** *** Rest is good
*************** ***********
MinWageCol.Item Style.Horizonta lAlign = HorizontalAlign .Center
Dim VarCol As BoundColumn = New BoundColumn()
'Set Headers
If (Session("Langu age") Is "en-CA") Then
ProvCol.HeaderT ext = "Province"
EffDateCol.Head erText = "Effective Date"
MinWageCol.Head erText = "Minimum Wage"
VarCol.HeaderTe xt = "Condition"
VarCol.DataFiel d = "english_te xt"
Else
ProvCol.HeaderT ext = "Administration "
EffDateCol.Head erText = "Date d'entrée en vigueur"
MinWageCol.Head erText = "Salaire minimum"
VarCol.HeaderTe xt = "Remarque"
VarCol.DataFiel d = "french_tex t"
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
10618
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 8.0;HDR=yes;\""; and one of to methods for inserting data. First I simply tried building insert statements as strings "insert into (, ) values ('Some text', 42)"
3
2444
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 parameter I'm using is > cmd.Parameters.Add(New SQLParameter("@thedate", thedate.text))
3
16653
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 columns of the combo box. Since the bound column property determines which value to look at, how do I change the bound column's value in an onClick event?
3
1100
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 cannot figure out how to get these via an sql command. Can anyone help? Thanks, Glenn
2
2355
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 | 1291 22964837 | 3105 22964838 | 199
5
33912
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
1949
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 does not keep the rows, as usual, but holds the single _columns_ as lists. In this case, every column could have it's own datatype, just like database-tables and could be sortable by the list's sort function.
3
3293
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 result, the data is mostly stored quite inefficiently as varchars. For example, there is data that could be stored in a column of bits and it's stored as a varchar value of 0 or 1. (Yuck, I know.) I am building a reporting system using this raw...
0
2130
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, and Column Count = 2, Column Widths 0cm;3cm I get the display I want. However, if I change the Bound Column to 2, this changes the values displayed – I now get column 1 values (RoomID) displaying, regardless of what I set for the Column Count and...
0
7993
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
7920
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8401
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8404
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8268
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
5440
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
3900
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2418
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
0
1254
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.