Solved

ASP datagrid multiple footer template?

Posted on 2006-07-16
2
450 Views
Last Modified: 2006-11-18
I have a datagrid that needs multiple footer lables for a shopping cart (Sub Total, TAX, Grand Total).

So far I can successfully create a single total like so, but...............

[Code Behind C#]
  public void DataGrid1_ItemDataBound(object sender, DataGridItemEventArgs e)
  {
        if (e.Item.ItemType == ListItemType.Footer)
        {
            e.Item.Cells[2].Text = "Sub Total:";
            e.Item.Cells[3].Text = string.Format("{0:c}", total);
        }

[ASPX]
  <FooterTemplate>
<table>
<tr>
<td>
<asp:Label ID="Label1" runat="server" Text='123'></asp:Label>
</td>
<tr>
<tr>
<td>
<asp:Label ID="Label2" runat="server" Text='456'></asp:Label>
</td>
<tr>
</table>
</FooterTemplate>
0
Comment
Question by:kvnsdr
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 15

Accepted Solution

by:
Solar_Flare earned 250 total points
ID: 17118365
is the problem that you cant add up the totals or cant add more labels/rows to the footer?
0
 
LVL 1

Author Comment

by:kvnsdr
ID: 17118516
I think the most confusing part of programming is that there are several ways to do the same thing.

I attempt to find the most simple and effective like this one I found at EE.

http://www.experts-exchange.com/Programming/Programming_Languages/Dot_Net/ASP_DOT_NET/Q_21457879.html?query=Multiple+footers&topics=865

It does do the trick, however I'm now having trouble formating my results correctly so they will show in the footer.

Total: $4.00    // Correct
Tax:   $0.00    // Should be .24
Total: $0.00    // Should be $4.24


decimal Tax = Convert.ToDecimal(.06);
decimal TaxedAmt = total * (1 + dInTax);

       
e.Item.Cells[2].Text = "Sub:" + "<br>" +
                                 "Tax" + "<br>" +
                                 "Total";

e.Item.Cells[3].Text = string.Format("{0:c}", total) + "<br>" +
                                 string.Format("{0:c}", Tax)  + "<br>" +
                                 string.Format("{0:c}", TaxedAmt);
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

737 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question