Olav:
This might be overkill, but my personal preference would be to create a
custom server control which inherits from Label (assuming these are just
text), or TextBox (if the user can enter information), something as simple
as:
this code is just from the top of my head, but something like it ought to
work.
public class PriceDisplay
Inherits Label
private _price as decimal
public property Price() as Decimal
get
return _price
end get
set (ByVal value as Decimal)
_price = value
end set
end property
Protected Overrides Sub Render(ByVal writer As
System.Web.UI.HtmlTextWriter)
If SHOULD_CALCULATE_TAX Then
_price = _price * (1 + GetTaxAmount())
End If
MyBase.Text = _price.ToString()
End Sub
end class
not that you can use a format string inside ToString() to get it to render
just like you want...
anyways, that's my $0.02...realize that I obviously left the the
SHOULD_CALCULATE_TAX logic as well as the GetTaxAmount() up to you to do...
Karl
--
MY ASP.Net tutorials
http://www.openmymind.net/
"Olav Tollefsen" <x@y.com> wrote in message
news:u%****************@TK2MSFTNGP12.phx.gbl...
I'm creating an ASP.NET e-commerce web site and I have to conditionally
(depending on site / user settings) display prices either excluding or
including tax. Prices are typically read from a database (where also the
tax rates are stored) various places in the code and typically (but now
always) the values are returned in DataSets which are bound to controls and
displayed to the user.
What would be the most elegant way to implement the logic to add tax to
the values presented to the user depending on some kind of setting?
Olav