Solved

Formatting Fields in custom binding in asp.net 2.0

Posted on 2006-11-13
5
367 Views
Last Modified: 2008-02-01
Hello...

I am using Visual Web Developer 2005 and I created a sql datasource and bound it to a formview.  In my ItemTemplate I need to show a number field as currency or 125422.55 as $125,422.55.  When I go to Edit Databinding for that field it has Custom Binding selected and Bind("fieldname") in the textbox.  Doesn't seem like there is anywhere obvious to format the field.  

Thanks!
0
Comment
Question by:kenadelglass
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 20

Expert Comment

by:REA_ANDREW
ID: 17931160
have you tried using DataFormatString?

so in your custom binding, have this in your tag line

dataformatstring="${0:C2}"




0
 
LVL 9

Expert Comment

by:kraffay
ID: 17931244
Can you set a HTMLEncode = "false" in your template?
0
 
LVL 52

Accepted Solution

by:
Carl Tawn earned 100 total points
ID: 17931286
You actually need to do both.

1) Set HTMLEncode = False
2) Set the DataFormatString to {0:c}

You don't need the $ symbol at the start because that is added for you depending on the current Culture.
0
 
LVL 11

Expert Comment

by:ethoths
ID: 17931553
You can have total control over the foprmat if you use...

myNumber.ToString("$" & "#,###.00")

This will use 2 decimal places, comma seperators and the currency symbol of your choice irrespective of the locale. If I were to browes a US site fomr the UK and you were using the locale to set the currency symbol, I would not be seeing the correct price (exchange rates).

Of course you can ignore this if you do want to use the servers locale to set the client side formatting.



0
 
LVL 1

Author Comment

by:kenadelglass
ID: 17932335
I sort of figured it out myself but the answers led to the right place...This was the binding statement that worked...

Bind("Networth", "{0:C}")

Thanks all for your efforts!
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question