473,394 Members | 1,869 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,394 software developers and data experts.

Data Binding and formatting

Where can I find a fairly comprehensive list of the formatting codes used
when data binding. e.g. <%# Bind("Debit", "{0:C}") %>. Specifically
formatting a number to 2 decimal places. Regards, Chris.

Jul 7 '06 #1
7 12677
use "{0:C2}" for 2 decimal places..

"Chris" <no****@btinternet.comwrote in message
news:ee**************@TK2MSFTNGP03.phx.gbl...
Where can I find a fairly comprehensive list of the formatting codes used
when data binding. e.g. <%# Bind("Debit", "{0:C}") %>. Specifically
formatting a number to 2 decimal places. Regards, Chris.

Jul 7 '06 #2
Chris,

Eval and Bind both use string.Format(). Here is a good reference for that:

http://msdn2.microsoft.com/en-us/library/fht0f5be.aspx

--

Andrew Robinson
http://blog.binaryocean.com
"Chris" <no****@btinternet.comwrote in message
news:ee**************@TK2MSFTNGP03.phx.gbl...
Where can I find a fairly comprehensive list of the formatting codes used
when data binding. e.g. <%# Bind("Debit", "{0:C}") %>. Specifically
formatting a number to 2 decimal places. Regards, Chris.

Jul 7 '06 #3
"{0:C2}" is for currency formats

when formatting a number to 2 decimal places, use

"{0:n2}"

http://authors.aspalliance.com/aspxt...atstrings.aspx

Jul 7 '06 #4

Winista wrote:
use "{0:C2}" for 2 decimal places..

"Chris" <no****@btinternet.comwrote in message
news:ee**************@TK2MSFTNGP03.phx.gbl...
Where can I find a fairly comprehensive list of the formatting codes used
when data binding. e.g. <%# Bind("Debit", "{0:C}") %>. Specifically
formatting a number to 2 decimal places. Regards, Chris.
On a related note, what does the "0" in {0:C2} indicate? I've seen
references to {1:xx} as well, though I've never seen it implemented.

Rich

Jul 8 '06 #5
Rich,

the 0 in {0:C2} is the placeholder for the variable you are formatting.

You could say:
double myMoney = 1;
double yourMoney = 2;
string foo = string.Format("My money is {0:C3}, and your money is
{1:C3}.", myMoney, yourMoney);

foo would be "My money is $1.000, and your money is $2.000.

Chris

Jul 8 '06 #6
chris wrote:
Rich,

the 0 in {0:C2} is the placeholder for the variable you are formatting.

You could say:
double myMoney = 1;
double yourMoney = 2;
string foo = string.Format("My money is {0:C3}, and your money is
{1:C3}.", myMoney, yourMoney);

foo would be "My money is $1.000, and your money is $2.000.
Thanks, chris. Out of curiosity, is that a known function from C or
something introduced with .Net? It looks familiar, but I don't recall
every encountering it in VB.

Rich

Jul 8 '06 #7
Not Sure Rich.

Jul 8 '06 #8

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

Similar topics

1
by: Saix News | last post by:
hi, i have a dataset and a number of controls that are bound to it. some of the records being displayed are numerical and are bound to text boxes. they display without a problem but i would...
3
by: Richard Urwin | last post by:
I'm using C# and having problems getting the 'Parse' EventHandler of my binding object to be called. Interestingly, the 'Format' method is always called however. A code snippet: (rdDocument is a...
2
by: | last post by:
I've defined an ObjectDataSource against a dataset, and I can bind the ObjectDataSource's members to data controls. I'm wondering how to take the values in an ObjectDataSource and...
4
by: hope | last post by:
Hi, How can I format a string field using Data Formatting Expression property in datagrid? For example: format last name from BROWN to Brown. Thanks
1
by: msmcg | last post by:
I need to format the data in some textboxes using the Binding method with custom Currency and ShortDate format and parse handlers. Here is the code that I am using. I call it on the form load...
1
by: Parveen | last post by:
I noticed that any formatting of the grid before data binding is lost after the grid is bound to a data table in the dataset. Is it possible to format the appearance of the data that shows up in...
10
by: Fares Eidi | last post by:
I am a VB6 intermediate programmer just starting out using VB.net and would like to ask what I'd be missing out on if I just use time saving techniques like data binding, data adapter wizards etc...
1
by: =?Utf-8?B?Q2hyaXMgRy4=?= | last post by:
Hey all, I'm coming from the ColdFusion world and am pretty new to .Net2. My issue is, I've got a page where the content (with html formatting included) is stored in a db table field. In MS...
6
by: Tomasz J | last post by:
Hello developers, I bind my TextBox control specyfying a format stored in my application global ApplicationContext object - it has a static string CurrencyFormat property. The problem - this...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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: 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
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,...
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
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...

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.