Link to home
Start Free TrialLog in
Avatar of RayBanUK
RayBanUK

asked on

Shopping Cart using Datalist - Help

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>
==========================================
ASKER CERTIFIED SOLUTION
Avatar of AerosSaga
AerosSaga

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of RayBanUK
RayBanUK

ASKER

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.
No problem my friend, glad to hear you got it worked out.

Aeros