473,757 Members | 2,284 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 12699
use "{0:C2}" for 2 decimal places..

"Chris" <no****@btinter net.comwrote in message
news:ee******** ******@TK2MSFTN GP03.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****@btinter net.comwrote in message
news:ee******** ******@TK2MSFTN GP03.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****@btinter net.comwrote in message
news:ee******** ******@TK2MSFTN GP03.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
1699
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 like to be able to format the numbers being displayed using thousand separators, etc. could someone please point me in the right direction as to how to do this - i have not been able to find a way of doing this.
3
2045
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 private member field of the class and has a string-type property called 'Name') Binding bName = new Binding("Text", rdDocument, "Name"); bName.Format += new ConvertEventHandler(teName_Format); bName.Parse += new...
2
9626
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 programmatically manipulate them before they're bound to any data control. I'd be using them almost like you'd use recordset fields from Classic ADO. In other words, I would like to grab the value corresponding to a publication date from my database, use the...
4
3234
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
3918
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 event: Private Sub setTextBoxDataBindings()
1
1226
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 the data grid after data binding (i.e. changing column names, giving combolists for columns, etc)?
10
1924
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 to create my front end application. Building the data access forms using manual coding just seems like a lot of work.... Any guidance would be appreciated Fares
1
1258
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 Access, the field type was Memo, in SSExpress I'm using nvarchar(max). When I try to display the contents/paragraphs in my aspx page (using Gridview) , I see all the html coding & formatting characters. Am I using the right data type? Should I be...
6
4607
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 works fine: Text='<%# Eval("Price", ApplicationContext.CurrencyFormat) %>'
0
9487
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...
1
9884
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 most users, this new feature is actually very convenient. If you want to control the update process,...
0
9735
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
8736
agi2029
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 launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7285
isladogs
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 instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6556
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
5324
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3828
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
3
3395
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.