Hi, I need to show on a label the data coming from db and it must show a
currency... I'm using a SqlDataReader reader, but doesnt work...
lblPreco.Text = Eval(reader[1].ToString(), "{0:c}");
Can you help me ? Thanks!
VS 2005 asp.net C# 2.0 4 3619
"Show currency" is kind of vague....as "does not work"....I bet it works
just does not give you result you want :)
After you did reader[1].ToString() it becomes string and you can not apply
{0:c} to it. Since it only applicable to Decimal datatypes (numerics
probably too).
Not sure why you doing it that way
lblPreco.Text = reader.GetDecim al(1).ToString( "c") should work...
Plus it's much faster ....
George.
"Paulo" <er********@ter ra.com.brwrote in message
news:eG******** ******@TK2MSFTN GP05.phx.gbl...
Hi, I need to show on a label the data coming from db and it must show a
currency... I'm using a SqlDataReader reader, but doesnt work...
lblPreco.Text = Eval(reader[1].ToString(), "{0:c}");
Can you help me ? Thanks!
VS 2005 asp.net C# 2.0
George, I found something on google:
lblPreco.Text = string.Format(" {0:c}", reader[1]);
Thank you very much!
"George Ter-Saakov" <gt****@cardone .comescreveu na mensagem
news:%2******** ********@TK2MSF TNGP04.phx.gbl. ..
"Show currency" is kind of vague....as "does not work"....I bet it works
just does not give you result you want :)
After you did reader[1].ToString() it becomes string and you can not apply
{0:c} to it. Since it only applicable to Decimal datatypes (numerics
probably too).
Not sure why you doing it that way
lblPreco.Text = reader.GetDecim al(1).ToString( "c") should work...
Plus it's much faster ....
George.
"Paulo" <er********@ter ra.com.brwrote in message
news:eG******** ******@TK2MSFTN GP05.phx.gbl...
>Hi, I need to show on a label the data coming from db and it must show a currency... I'm using a SqlDataReader reader, but doesnt work...
lblPreco.Tex t = Eval(reader[1].ToString(), "{0:c}");
Can you help me ? Thanks!
VS 2005 asp.net C# 2.0
Agreed.
You should always pick the granular "get".
..GetString()
..GetDateTime
..GetInt32()
etc, etc.
Instead of .GetValue() ... or how you're (mis) using the ToString().
"George Ter-Saakov" <gt****@cardone .comwrote in message
news:%2******** ********@TK2MSF TNGP04.phx.gbl. ..
"Show currency" is kind of vague....as "does not work"....I bet it works
just does not give you result you want :)
After you did reader[1].ToString() it becomes string and you can not apply
{0:c} to it. Since it only applicable to Decimal datatypes (numerics
probably too).
Not sure why you doing it that way
lblPreco.Text = reader.GetDecim al(1).ToString( "c") should work...
Plus it's much faster ....
George.
"Paulo" <er********@ter ra.com.brwrote in message
news:eG******** ******@TK2MSFTN GP05.phx.gbl...
>Hi, I need to show on a label the data coming from db and it must show a currency... I'm using a SqlDataReader reader, but doesnt work...
lblPreco.Tex t = Eval(reader[1].ToString(), "{0:c}");
Can you help me ? Thanks!
VS 2005 asp.net C# 2.0
That is pretty much the same thing except slower :)
reader[1] returns an object that is actually has type Decimal.
Then you leave string.Format to figure it out and apply {0:c} accordingly.
with reader.GetDecim al(1).ToString( "c") the guessing of which type reader[1]
is already done by you. Since GetDecimal returns Decimal.
George.
"Paulo" <er********@ter ra.com.brwrote in message
news:OK******** ******@TK2MSFTN GP04.phx.gbl...
George, I found something on google:
lblPreco.Text = string.Format(" {0:c}", reader[1]);
Thank you very much!
"George Ter-Saakov" <gt****@cardone .comescreveu na mensagem
news:%2******** ********@TK2MSF TNGP04.phx.gbl. ..
>"Show currency" is kind of vague....as "does not work"....I bet it works just does not give you result you want :)
After you did reader[1].ToString() it becomes string and you can not apply {0:c} to it. Since it only applicable to Decimal datatypes (numerics probably too).
Not sure why you doing it that way
lblPreco.Tex t = reader.GetDecim al(1).ToString( "c") should work... Plus it's much faster ....
George.
"Paulo" <er********@ter ra.com.brwrote in message news:eG******* *******@TK2MSFT NGP05.phx.gbl.. .
>>Hi, I need to show on a label the data coming from db and it must show a currency... I'm using a SqlDataReader reader, but doesnt work...
lblPreco.Te xt = Eval(reader[1].ToString(), "{0:c}");
Can you help me ? Thanks!
VS 2005 asp.net C# 2.0 This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Bill Partridge |
last post by:
I am being very dumb... I am coverting an invoice value to a decimal and
displaying the result on a VB.net 2003 form. However, I only want to display
the result to 2 decimal places and I am struggling to it - sorry for such an
easy question!
Can somebody advice me how to achieve this?
--
Thanks
|
by: Dalan |
last post by:
This should not be an issue, but it is. I'm sure that someone knows
what little piece of code is needed too persuade Access 97 to include
a currency format for labels (Avery, mailing type). Have had no
problems with currency formatting on reports - just the labels.
Doesn't matter if the associated field in the Table and Form have
Format as...
|
by: hallman |
last post by:
I have data that I would like to format just so:
2000 to be $2,000
-2000 to be ($2,000)
2000.01 to be $2,000.01
2000.1234 to be $2,000.1234
The 'canned' Currency format type
*rounds* the fractions of a cent to the nearest cent.
|
by: VB Programmer |
last post by:
I have a datalist that contains a label for each time to hold pricing info.
In the Access db everything is stored in a currency format. But, when the
label displays the info it's not in currency format, with 2 decimals, etc...
Any ideas how I can force the label to display a currency format?
Thanks!
|
by: nbohana |
last post by:
I have a textbox that displays money, I cannot find out how to format it so
it displayes like '$123.00' what i get now is '123.00'. Can someone point me
in the right direction?
Thanks in advance!!!
--
Norm Bohana
| |
by: Scott M. |
last post by:
Ok, this is driving me nuts...
I am using VS.NET 2003 and trying to take an item out of a row in a
loosely-typed dataset and place it in a label as a currency. As it is now,
I am getting my unformatted data values (as decimals) just fine, so I know
there's not a problem with the data retrieval, just the formatting.
I have read that this...
|
by: Akinyemi |
last post by:
I am currently puting finishing touches to a Tax Computin Software. But I am worried about the number of decimal place the program displays - Four decimal place. And some of the fields display only one decimal place while some do not at all!
The program has Basic Salary, Housing Allowance ..., Gross Pay , Reliefs, Taxable Pay, Annual Tax...
|
by: Ikraams |
last post by:
I have two sheets (A3 size) reports. Both are same except the values in different currency. The other is paste link to the first. The problem is when I add text then have to maually adjust rows and collumn in the second sheet. Is there a way even the formating will change in second sheet simultaneously like the cell values?
|
by: najmi |
last post by:
hai guys...do you know how to formating the currency data from database into java form
|
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...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
| |
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...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes...
|
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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
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
| |
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...
| |