Formatting an ASP Repeater Container Data Item

I have a repeater that is loaded with a sql data reader in my start page. One of the fields I need is the price of the product and when I use the repeater, I can only access the data via <%#Container.DataItem("dblBasePrice") %>

 Is there a tag in ASP that I can put between the container.dataitem to format the number as currency?

Thanks,
LR
Luis_RomeroAsked:
Who is Participating?
 
chaniewskimCommented:
You can use syntax

<%# DataBinder.Eval(Container.DataItem, "dblBasePrice", "{0:C}") %>
0
 
SteveGTRCommented:
You could do either of these:

<%# DataBinder.Eval(Container.DataItem, "dblBasePrice", "{0:c}") %>

or this (faster):

<%# String.Format("{0:c}", ((DataRowView) Container.DataItem)["dblBasePrice"]) %>

Good Luck,
Steve
0
 
SteveGTRCommented:
Right behind you again chaniewskim.

Can you wait 5 minutes before you post the next time? :)
0
Cloud Class® Course: Microsoft Azure 2017

Azure has a changed a lot since it was originally introduce by adding new services and features. Do you know everything you need to about Azure? This course will teach you about the Azure App Service, monitoring and application insights, DevOps, and Team Services.

 
chaniewskimCommented:
Steve,
I'll try ;)
0
 
Luis_RomeroAuthor Commented:
Thank you both for your help.

Where can I find more information on the DataBinder.Val method? as well as for the DataRow View method?

Thanks,
0
 
SteveGTRCommented:
You can find help on these subject by going to:

http://www.msdn.microsoft.com/

And typing them in Search MSDN for.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.