473,396 Members | 2,129 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Do calculations in repeater

Hi All,

I'm quite new to ASP.net and i can't figure out one thing.
I would like to add the total price and the total discount to 2 different
variables so when my reapeater is finished i've got my data on the screen
and the total price and the total discount

So far i've got this code wish works fine to show the data but it doesn't do
any calculation

Dim query As String
kid = Request.QueryString("kid")
//this query is a very simple versiono of the real one
query = "SELECT Title, ArtistName, Price DefaultPrice,Discount WHERE
CustomerID = '" & kid & "'
connection = New SqlConnection(connectionString)
connection.Open()
Dim commando As SqlCommand = New SqlCommand(query, connection)
Dim reader As SqlDataReader = commando.ExecuteReader()
Dim TotalPrice As Double

voorstellingen.DataSource = reader
voorstellingen.DataBind()
reader.Close()
connection.Close()
getKlantGegevens()

So i would like to fill a variable with the total price and a variable with
the total discount.

Thanks in advance
Erik
Nov 18 '05 #1
2 2081
In general, it is best to go ahead and calculate aggregates in the database
and simply pass back the results. Doing so not only enhances performance, but
increases maintainability of the ASPX pages and their code behind.

If you have to manipulate in the ASPX and/or its code behind, you may be
able to bind to a function that does the calculation. It is a one way trip,
however. If you need complete flexibility, you are better creating the output
yourself, rather than using a repeater. This can be a simple table creation
in the code behind or a custom control. You will probably find you do not
need to go to this step if you will simply calculate in the database.

---

Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

***************************
Think Outside the Box!
***************************

"ha**@none.com" wrote:
Hi All,

I'm quite new to ASP.net and i can't figure out one thing.
I would like to add the total price and the total discount to 2 different
variables so when my reapeater is finished i've got my data on the screen
and the total price and the total discount

So far i've got this code wish works fine to show the data but it doesn't do
any calculation

Dim query As String
kid = Request.QueryString("kid")
//this query is a very simple versiono of the real one
query = "SELECT Title, ArtistName, Price DefaultPrice,Discount WHERE
CustomerID = '" & kid & "'
connection = New SqlConnection(connectionString)
connection.Open()
Dim commando As SqlCommand = New SqlCommand(query, connection)
Dim reader As SqlDataReader = commando.ExecuteReader()
Dim TotalPrice As Double

voorstellingen.DataSource = reader
voorstellingen.DataBind()
reader.Close()
connection.Close()
getKlantGegevens()

So i would like to fill a variable with the total price and a variable with
the total discount.

Thanks in advance
Erik

Nov 18 '05 #2
if you wanna do calculations in a repeater, you need to use the on
ItemDataBound command.
Than for every item, increment a variable by the value required.

When the Repeated is finished binding, the value will be in the variable
<ha**@none.com> wrote in message
news:41*********************@dreader6.news.xs4all. nl...
Hi All,

I'm quite new to ASP.net and i can't figure out one thing.
I would like to add the total price and the total discount to 2 different
variables so when my reapeater is finished i've got my data on the screen
and the total price and the total discount

So far i've got this code wish works fine to show the data but it doesn't
do
any calculation

Dim query As String
kid = Request.QueryString("kid")
//this query is a very simple versiono of the real one
query = "SELECT Title, ArtistName, Price DefaultPrice,Discount
WHERE
CustomerID = '" & kid & "'
connection = New SqlConnection(connectionString)
connection.Open()
Dim commando As SqlCommand = New SqlCommand(query, connection)
Dim reader As SqlDataReader = commando.ExecuteReader()
Dim TotalPrice As Double

voorstellingen.DataSource = reader
voorstellingen.DataBind()
reader.Close()
connection.Close()
getKlantGegevens()

So i would like to fill a variable with the total price and a variable
with
the total discount.

Thanks in advance
Erik

Nov 18 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Ed Allan | last post by:
http://ejaconsulting.com/nestedrepeater/NestedRepeater.txt >-----Original Message----- >Doh! The HTML has all been rendered . . . > >Right click on this link and select 'Save target as ..' >to...
8
by: Invalidlastname | last post by:
Hi, We are developing an asp.net application, and we dynamically created certain literal controls to represent some read-only text for certain editable controls. However, recently we found an issue...
0
by: Amir | last post by:
Hi every one This is the problem: I have a UserControl that contains a Repeater and a few LinkButton. The Repeater generate some linkButton. I use this control for implementing paging solution...
3
by: sorCrer | last post by:
Hi All, Posted after extensive searching! I have a nested repeater control as follows: (Simplified ;-)) <table> <asp:repeater id=parent onItemDataBound=createChild> <tr><td>Level...
8
by: I am Sam | last post by:
Hi everyone, This problem is making me old. I don't want to get any older. I have a multi-nested repeater control as follows: <asp:Repeater ID="clubRep1" Runat="server">...
1
by: olduncleamos | last post by:
Hello all, I am experimenting with the repeater control and ran into something that I wasn't expecting. I would appreciate if the experts can confirm or correct my understanding. Here is a...
2
by: GD | last post by:
I'd like to use a Repeater to display data coming back from a cross-tab report. Because it's a cross-tab, I generally don't know how many columns are coming back. They do follow a certain format: ...
8
by: fernandezr | last post by:
I would like to use a user control as a template inside a repeater. Some of the fields in the control should be hidden depending on whether or not there is data. I'm still a ASP .Net newbie so the...
0
by: uncensored | last post by:
Hello everyone, I'm fairly new at .Net and I have a repeater inside a repeater problem. I will attach my code to this message but basically what I am able to tell when I run my page it tells me...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.