Solved

ASP datagrid multiple footer template?

Posted on 2006-07-16
2
439 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
2 Comments
 
LVL 15

Accepted Solution

by:
Solar_Flare earned 250 total points
Comment Utility
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
Comment Utility
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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Lots of people ask this question on how to extend the “MembershipProvider” to make use of custom authentication like using existing database or make use of some other way of authentication. Many blogs show you how to extend the membership provider c…
A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

762 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now