Sum of Columns in Repeater Control

Hello Everyone,

 I am currently working on a project in .NET framework 1.1 and using the Visual Studios 2003 IDK. In my project I have a repeater control with 10 columns. Out of those 10, I need 8 to be sub-totaled in the bottom of each. What is the easiest way to calculate the sum of the values that are shown in each column dynamically? Thank you and I will highly appreciate your help in this matter. Also, I am a new developer so please be very simplistic in your reply. I'm still in the learning process. Thanks again.






4/29/2008 10:05:43 PM 72751 articles. 3 followers. Follow

1 Replies

Similar Articles

[PageSpeed] 12

Hi omaleem ,

In this secnairo, I recommend you to use DataGrid control.

see my sample,


    protected void Page_Load(object sender, EventArgs e)
        if (!IsPostBack)
    private void bind()
        DataTable table = new DataTable();
        for (int i = 0; i < 10; i++)
            DataRow dr = table.NewRow();
            dr["pay"] = i.ToString();
            dr["money"] = i.ToString();
        this.dg.DataSource = table;


    private double sumofpay = 0;
    private double sumofmoney = 0;
    protected void dg_ItemDataBound(object sender, DataGridItemEventArgs e)
        Label pay = e.Item.FindControl("Label1") as Label;
        Label money = e.Item.FindControl("Label2") as Label;
        if (pay != null)
            sumofpay += Convert.ToDouble(pay.Text);
            sumofmoney += Convert.ToDouble(money.Text);
        Label lblsumpay = e.Item.FindControl("Label3") as Label;
        Label lblsummoney = e.Item.FindControl("Label4") as Label;

        if (lblsumpay != null)
            lblsumpay.Text = sumofpay.ToString ();
            lblsummoney.Text = sumofmoney.ToString ();

   <asp:DataGrid runat="server" ID='dg' AutoGenerateColumns="False" OnItemDataBound="dg_ItemDataBound" ShowFooter="True" Width="189px" >
                    <asp:Label ID="Label3" runat="server" Text="Label"></asp:Label>
                    <asp:Label ID="Label1" runat="server" Text='<%# Eval("pay") %>' Width="120px"></asp:Label>
                    <asp:Label ID="Label4" runat="server" Text="Label"></asp:Label>
                    <asp:Label ID="Label2" runat="server" Text='<%# Eval("money") %>'></asp:Label>

Samu Zhang
Microsoft Online Community Support

Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question.
5/1/2008 2:57:44 AM

Similar Artilces:

Repeater control in another repeater control
Hi, I want Repeater control in another repeater control but it is not working Code : <asp:Repeater ID=CourseMaster Runat=server > <ItemTemplate> <table border=0 cellpadding=0 cellspacing=0 style="font-family:tahoma;font-size:12"> <tr> <td >&nbsp;<b</b></td> </tr> <tr> <td> <asp:repeater ID="CourseDetails" Runat=server> <ItemTemplate> <tab...

Data presentation control in another Data presentation control
 Hello,I want to make a menu with datalist or gridview control.Basically,the menu will be like this,Categories     Sub Categories.For example, for COMPUTING category there will be NOTEBOOKS DESKTOPS etc.There will be a image for CATEGORIES and linkbuttons with Subcategories.If I put a datalist inside a datalist and a link button inside the second datalist visually it satisfies my need.However,CommandArguments come from database to linkbutton.Andwhen one of these command buttons is cliked it must go to proper page.I dont know how to wrie an event_handler ,specifically, for...

Responding to control in Repeater Control
I'm attempting to respond to events by a dropdownlost/checkbox/radiobutton and I am having trouble getting the code to do this to work. For the aspx file I have tried setting the function to call in the dropdownlist in the OnSelectedIndexChanged property yet. That causes the module to have an unhandled error when I attempt to view it. This also happens when I put it in the repeater controls OnItemCommand="SetNewUpline", the module becomes unloadable. My function looks like         private void SetNewUpline(object sender, RepeaterCommandEventArgs e) ...

how to radiobuttonlist control in repeater control?
Hi there, I tried this code for nested repeater control.  The following code is working fine. Only the thing is  I want radio buttons instead of bullet points.Could any  one help me in  that?  In reapeater.aspx<%@ Page Language="C#" MasterPageFile="~/Admin/MasterPage.master" AutoEventWireup="true" CodeFile="repeater.aspx.cs" Inherits="repeater" Title="Untitled Page" %> <%@ Import Namespace="System.Data" %> <asp:Content ID="Content1" ContentPlaceHolderID="ContentP...

Repeater control in a composite control...
How do I put a repeater control in a composit control. Currently, I putting textbox, dropdowns, etc. There is a very small different between the dropdownlist and repeater if both of then are databound. Basically, all you need to cater for is databinding of the Repeater during the databinding of your composite control BugBug [MCSD]...

Get control in repeater control
Dear all, I want to use HtmlControls.HtmlTableCell in repeater control but i cant not access it,  in my table in Repeater Control,  i have 2 "td" which on page_load, i want to show only 1 of them depend on condition given. But i cant do it. This is my code : <asp:repeater id="repeaterViewNew" runat="server">                   <HeaderTemplate>                      <table width="100%" cellpadding="1" cellspacing="1">   &...

select control in a repeater control

refering to controls in a repeater control
Hey, (this is an example situation) I have a repeater control which displays a textbox. As the repeater control is 'run' when the page is loaded. I'd like to give a unique id to each textbox. ie: name1, name2, name3, name4 etc. And I'd also like to store the number of times the repeater control is 'iterated' through. I imagine the best way to store the number of times is to either return a values with my select query (Stored Procedure), or to increment a cached int each time I run through the repeater control. How would I assign a 'unique' id to each textbox? Thanks ...

Custom Control within a Control Control
I am developing a custom controls that will render headers for different web sites. Within these controls, I want to place another custom control that will change the language. I created the language control and had it implement IPostBackDataHandler. This control works fine if I drag it on a new web form, but if I tell a header custom control to render it problems occur. The Language Selector custom control does not have a Page member anymore and the event handlers do not work. Does anyone have any experience with doing something similiar? Anyone have any suggestions? Thanks, ...

How do I control one control from another control?
I have a page page1.aspx which is within a master page. On page I have a table with two cells. Within each cell I have placed two controls (ascx) that I have developed. Now I'd like to be able to get these two controls to interact. One needs to update the other. One has some search criteria that the other one needs to update its gridview. One needs to make the other visible/not visible at certain times. Out of the box neither control can see each other at all. Is there a good article or someplace I can find some information on how to do this? Information Technolo...

Calendar Control inside Repeater, Handling Child control events in parent Data Control
Hi all,I've been researching a problem i have for a couple of days now and i'm still not sure how to even start to handle it.I'm essentially trying to build a page that will display custom form fields/controls for individual items/rows inside a repeater.I've got a fairly complex calendar i need to have working inside each individual row of the Repeater. The calendar is set up to fire the following events: OnDayRender="Calendar2_DayRender" OnSelectionChanged="Calendar2_SelectionChanged" OnVisibleMonthChanged="Calendar2_VisibleMonthChanged"My first question is how do i go about handling these...

Trouble controlling .net controlls with CSS
 I am trying to control the :hover css property on <asp: Button> controls. Basically the css is working correctly to set the initial look of the button, but nothing is happening when I hover over the button. Here is my code:CSS:.sidebarButton{    width: 168px;     height: 45px;     background-color: #666666;     text-align: left;    font-weight: bold;    font-family: Century Gothic;    font-size: 13pt;    color: White;    border-style: none;  ...

About Rating Control , palcing in repeater control
hello everybody, i am doing a proj. like Yahoo Questions and Answers. in this  my :; placing a  AJAX Rating Control within a repeater Control, to rate  each answer. Suggest me how 2 do this. it's very urgent.... Hi,Please refer to this post: The sample I posted has a Rating control for each row.Hope this helps. ...

Server controls within a Repeater control...
Hello,I have this panel within a repeater control named "repSub": <asp:Panel ID="<% #DataBinder.Eval(Container.DataItem, "pid") %>" runat="server"></asp:Panel>"pid" is a unique string identifierI keep getting a "Server tags cannot contain <% ... %> constructs." error. How can I programatically assign the string IDs to the Panel?   Hey, Try using single-quotes around the binding statement, instead of double-quotes.  And I don't know if you can dynamically set ID's but that would be cool if it did...Brian"Trust in the Lord and do what is g...

Web resources about - Sum of Columns in Repeater Control -

Repeaters - Wikipedia, the free encyclopedia
Kyle Halsted, Sonia Logan, and Michael Weeks are inmates at a rehabilitation facility. Bob Simpson, the administrator, tasks them with apologizing ...

Animal Repeater Memory Game HD Free Lite - for iPad for iPad on the iTunes App Store
Get Animal Repeater Memory Game HD Free Lite - for iPad on the App Store. See screenshots and ratings, and read customer reviews.

Consumers warned to beware of illegal mobile phone repeaters
Use of devices sold online as legitimate solution is in fact dangerous and can land you in jail, regulator warns.

Grim repeater: HIV on the rise
CANDLES flicker in the chilly night air as Jesse Hooper appears on the giant cinema screen overlooking Melbourne&#8217;s Federation Square. He&#8217;s ...

Telstra suspects underbelly of illegal repeaters
'Tens' busted each year. Telstra engineers suspect a "vast" undercurrent of illegal repeaters are causing issues for the carrier's Next G mobile ...

Hands on: Cel-Fi mobile repeater
If your home is a mobile blackspot then a Cel-Fi mobile repeater might help you stay connected.

Amped Wireless R20000G, SR20000G, and UA2000: Routers, Repeaters, and Adapters
... and throughput when pointed at your wireless router/access point. Rounding out the review, Amped sent a third product, their SR20000G repeater, ...

Photon heralds entanglement in new quantum repeater
... For ordinary electrical wires (such those used for ethernet), signals can travel long distances because they're boosted by means of repeaters ...

Celebrity Rehab Repeaters
Kate Middleton Bikini Photos 50 Shades of Grey Hollywood Couples Red Carpet The Kardashians Best Dressed Hot Bodies Celebrity Kids News Sightings ...

Computer networking: wireless networks (wifi), routers, repeaters & more - CNET Reviews
Computer networking reviews and ratings, video reviews, user opinions, most popular network hardware, wireless network buying guides, prices, ...

Resources last updated: 12/9/2015 7:59:37 AM