Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3878798
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T22:39:12+00:00 2026-05-19T22:39:12+00:00

I recently decided to implement tax on an ecommerce website I’ve built for fun

  • 0

I recently decided to implement tax on an ecommerce website I’ve built for fun more than anything and I’ve hit a stumbling block.

My implementation works well, tax is applied correctly etc, however a buddy pointed out to me today that prices on product pages are normally displayed inc tax.

I was thinking, rather than editing the Business and Data tier, I could change this on the DataList itself but I can’t for the life of me work out how I’d actually do that. I’ve had a look in some text books and had a search around online but because I don’t actually know what I’m looking for, I’m stuck :(.

Datalist:

<asp:DataList ID="list" runat="server" RepeatColumns="2" CssClass="ProductList" RepeatDirection="Horizontal" 
    Width="542px" EnableViewState="False" onitemcommand="list_ItemCommand">
<ItemTemplate>
<div style="width:271px;">
<h3 class="ProductName"><a href="<%# Link.ToProduct(Eval("ProductID").ToString()) %>"><%# HttpUtility.HtmlEncode(Eval("Name").ToString()) %></a></h3>
<a href="<%# Link.ToProduct(Eval("ProductID").ToString()) %>"><img width="100" border="0" src="<%# Link.ToProductImage(Eval("Thumbnail").ToString()) %>" alt='<%# HttpUtility.HtmlEncode(Eval("Name").ToString()) %>' /></a>
<%# HttpUtility.HtmlEncode(Eval("Description").ToString()) %>
<p>
<b>Price:</b>
<%# Eval("Price", "{0:c}") %>
</p>
<p>
<asp:Button ID="addToCartButton" runat="server" Text="Add to Basket" CommandArgument='<%# Eval("ProductID") %>' CssClass="SmallButtonText" />
</p>
</div>
</ItemTemplate>
</asp:DataList>

Code behind:

    // Retrieve the list of products in a Sub Category
    list.DataSource = CatalogAccess.GetProductsInSubCategory(subCategoryId, page, out howManyPages);
    list.DataBind();

E.g. if the price in the DB is £5, I’d need it to be displayed in the datalist above as £6 which includes the current UK VAT rate of 20%.

So:
DBPrice * 1.2 = IncVatPrice

I hope this makes sense!

Thanks in advance,
Matt

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-19T22:39:12+00:00Added an answer on May 19, 2026 at 10:39 pm

    Instead of

    <%# Eval("Price", "{0:c}") %>
    

    use an expression somewhat similar to

    <%# String.Format("{0:c}", (Decimal)Eval("Price")*1.2) %>
    

    Or implement a function in codebehind:

    protected string IncludeVat(object dataItem)
    {
      Decimal price = (Decimal)DataBinder.Eval(dataItem, "Price");
      return String.Format("{0:c}", price * 1.2);
    }
    

    and call it in your DataList like that

    <%# IncludeVat(Container.DataItem) %>
    

    http://www.pluralsight-training.net/community/blogs/fritz/archive/2005/12/16/17507.aspx

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm a beginner (self-learning) programmer learning C++, and recently I decided to implement a
I recently decided to try to learn some bash scripting and as a fun
I've recently decided that I just have to finally learn C/C++, and there is
This is starting to vex me. I recently decided to clear out my FTP,
I started a Rails project recently and decided to use RESTful controllers. I created
I recently started a new webforms project and decided to separate the business classes
I've recently seen the light of EventWaitHandle's powerful behavior in C# and decided to
I've been diving into Erlang recently, and I decided to use Mnesia to do
I recently decided that I needed to change from using milliseconds to microseconds for
I've recently decided to try an upgrade to 4.0. The only error I still

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.