Solved

Shopping Cart using Datalist - Help

Posted on 2004-10-04
3
368 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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

SSL stands for “Secure Sockets Layer” and an SSL certificate is a critical component to keeping your website safe, secured, and compliant. Any ecommerce website must have an SSL certificate to ensure the safe handling of sensitive information like…
Every business owner understands the significance of online customer reviews and the impact it can have on sales and revenues. With technology advancing at such a rapid pace, getting online reviews has never been easier, especially when many regions…
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.

760 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

26 Experts available now in Live!

Get 1:1 Help Now