call to service on data bound makes the code slower

I need to retrieve two values: Tax and Freight by calling a model that contains the line details.

The order that contains the code uses a different data model as its data source, order data header model.

I am able to get the values, by adding a call in the grid-view's data-bound event, to a method that is part of the line order data model, but that makes the code extremely slow when more than 100 orders get retrieved.

This is my code:
            'Get the Tax and Freight from the OrderService.OrderDataModel
            Dim orderList as Order
            orderList = New Orders(SiteKey)
            loadedOrder = orderList.Load(e.Row.DataItem.OrderID, strEnv)
            DirectCast(e.Row.FindControl("lblTax"), Literal).Text = String.Format("{0:C}", loadedOrder.Tax)
            DirectCast(e.Row.FindControl("lblFreight"), Literal).Text = String.Format("{0:C}", loadedOrder.Freight)

Open in new window


I am wondering if I should place the code somewhere else, like in the Load event of the page?

If I do move it to the Load event, how can I retrieve the Tax and Freight values for all orders, and bound them to the grid-view?

I am not sure how to do this using a loop, saving all the values, and pass the values to the data bound event.

I would like some help in what is the best practice method for doing this, and if possible some examples in code.

Many thanks.
the_lone_noteAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

David Johnson, CD, MVPOwnerCommented:
Tax and freight should be calculated when each order is created and then saved with the order

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP.NET

From novice to tech pro — start learning today.