Solved

Shopping Cart using Datalist - Help

Posted on 2004-10-04
3
371 Views
Last Modified: 2013-11-29
Im using a Datalist to list all items in a shopping cart. Im using ItemTemplate with HeaderTemplate for all the headings.

The only problem Im having is where do I put the totals? I would have thought it would be good to put it in the FooterTemplate but it doesnt like it when I put a Label in there. Do I have to do outside the Datalist and re-create another table? Please advise!

Heres my code (the data is DataBind(ed))

==========================================
 <asp:DataList class="MainText" id="BasketList" runat="server" width="100%" CellPadding="2" CellSpacing="2">
                                <HeaderTemplate>
                                    <tr>
                                        <td>
                                            ISBN
                                        </td>
                                        <td>
                                            Item</td>
                                        <td>
                                            Quantity</td>
                                        <td width="80" align="right">
                                            Price</td>
                                        <td width="80" align="right">
                                            Line Total</td>
                                        <td width="20"></td>
                                    </tr>
                                </HeaderTemplate>
                                <ItemTemplate>
                                    <tr valign="top">
                                        <td>
                                            <a href="bookdetails.aspx?ISBN=<%# DataBinder.Eval(Container.DataItem, "ISBN") %>"><%# DataBinder.Eval(Container.DataItem, "ISBN")%></a></td>
                                        <td>
                                            <p>
                                                <a href="bookdetails.aspx?ISBN=<%# DataBinder.Eval(Container.DataItem, "ISBN") %>"><strong><%# DataBinder.Eval(Container.DataItem, "Title") %></strong></a>
                                                <br />
                                                <%# DataBinder.Eval(Container.DataItem, "Subtitle") %>
                                                <br />
                                                <em><%# DataBinder.Eval(Container.DataItem, "Author") %></em>
                                            </p>
                                        </td>
                                        <td>
                                            <asp:TextBox id="Quantity" runat="server" Columns="4" MaxLength="3" Text='<%# DataBinder.Eval(Container.DataItem, "Quantity") %>' width="40px" />
                                        </td>
                                        <td align="right">
                                            <%# DataBinder.Eval(Container.DataItem, "Price", "{0:c}") %></td>
                                        <td align="right">
                                            <%# DataBinder.Eval(Container.DataItem, "LineTotal", "{0:c}") %></td>
                                        <td></td>
                                    </tr>
                                </ItemTemplate>
                            </asp:DataList>
==========================================
0
Comment
Question by:RayBanUK
  • 2
3 Comments
 
LVL 17

Accepted Solution

by:
AerosSaga earned 125 total points
ID: 12216461
If you want to put it in the control you will need to use a datagrid for this:

http://aspalliance.com/494
http://aspnet.4guysfromrolla.com/articles/020503-1.aspx
http://www.datawebcontrols.com/faqs/Footers/DisplayingFooterSummaryInformation.shtml

Other wise, just create a lable below the datalist and put your sums there.

Aeros
0
 

Author Comment

by:RayBanUK
ID: 12217769
Thank you, just what I needed, I found out before you posted you from a friend but will award points for finding detailed info from the web. Funny how I couldnt find them when I was looking for them! Obviosuly put wrong search words in google!

Thanks again.
0
 
LVL 17

Expert Comment

by:AerosSaga
ID: 12217782
No problem my friend, glad to hear you got it worked out.

Aeros
0

Featured Post

Does Powershell have you tied up in knots?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

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

Suggested Solutions

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…
ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
Viewers will get an overview of the benefits and risks of using Bitcoin to accept payments. What Bitcoin is: Legality: Risks: Benefits: Which businesses are best suited?: Other things you should know: How to get started:
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

773 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