Connecting Tech Pros Worldwide Forums | Help | Site Map

Formatting DataBound Controls

Newbie
 
Join Date: Apr 2007
Posts: 5
#1: Apr 27 '07
I am running into a problem that I cannot seem to solve.

I'm using ADO.NET 2.0 with vb 2005. I have a dataset as a datasource that selects all of the Shoe_Types from a Shoe_Type table. I am creating the data set and doing all of the data binding at runtime.

I then bind each label at run time by doing:
Expand|Select|Wrap|Line Numbers
  1. Me.lblShoeTypePrice.DataBindings.Add("text", Shoe_Type_DataTable, "Shoe_Price")
I'm not exactly sure how I should go about formatting the label so that it shows up as currency. The shoe price label will display a value like 4.0000 when I want it to be $4.00. The datatype for shoe price is currency in SQL Server 2005.

Right now I'm doing things like this:

Expand|Select|Wrap|Line Numbers
  1. Me.lblDailyCost.Text = FormatCurrency(Me.lblDailyCost.Text, 2)
I don't really like doing it that way since it could cause problems if there isn't a shoe type price.

I was wondering if formatting the datacolumn in the ShoeType DataTable to type currency would be best. Anyway...can anyone explain the common practice for this sort of thing? Thanks a ton!!
Newbie
 
Join Date: Apr 2007
Posts: 5
#2: Apr 27 '07

re: Formatting DataBound Controls


...Not sure how to just edit a post..but

So i've been searching on this topic all day and refined my google search and came across a similar post here at thescripts.com. Changing 2 words around can do the trick I guess. I'm gonna go over this [HTML]http://www.thescripts.com/forum/thread379170.html[/HTML]
later, but if anyone has any quick advice I'd love to hear it. Thanks
Reply