Solved

ASP datagrid multiple footer template?

Posted on 2006-07-16
2
451 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

I recently went through the process of creating a Calendar Control of events with the basis of using a database to keep track of the dates that are selectable, one requirement was to have the selected date pop-up in a simple lightbox.  At first this…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

691 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