Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
Hi All,
 
I am building a project in which I have to give user a functionality of shopping cart. I am able to create a shopping cart but I am getting a problem of displaying the shopping cart smoothly. The issue is that all of my products are inside a data list and on item Command event of data list I am inserting the products into the cart. The popping in and out is done by using java script entity not a function. Now when I use a button with a command name than it picks the new product but java script doesn't works and if I use link button java script works but it doesn't allow me to add anything to cart means cart pops up empty. Where am I getting wrong ???
Is this even a proper way of implementing a shopping cart ??? Here is my data list html mark up :
   <asp:DataList ID="DataList1" runat="server" OnItemDataBound="DataList1_ItemDataBound"
            OnItemCommand="DataList1_ItemCommand">
            <ItemTemplate>
                <div class="prdt_div">
                    <div class="prd_img">
                        <a class="jqzoom" rel='gal1' title="Earrings"  runat="server" id="img1">
                            <img src="~/images/thumb/er_sm02.jpg" alt=""  runat="server" id="img_thumb" /></a>
                    </div>
                    <div class="prd_descrip">
                        <ul>
                            <li class="titl">
                                <asp:Label runat="server" ID="lbl_ProdName" Text='<%# Eval("Product_Name") %>'></asp:Label></span></li>
                            <li>Our Price: <span>
                                <asp:Label runat="server" ID="lbl_price" Text='<%# Eval("Price_INR") %>'></asp:Label></span></li>
                            <li>Qty:
                                <asp:Label runat="server" ID="lbl_quntity" Text='<%# Eval("Quantity") %>'></asp:Label>
                            </li>
                            <li><a href="" data-reveal-id="myModal"  runat="server" id="order"   önserverclick="anchor1_serverclick">cart show </a>
                            <asp:Button ID="lbkBtnADD" CssClass="order_now" CommandName="Select" runat="server" OnClientClick="data-reveal-id:myModal"></asp:Button>
                                <asp:Label runat="server" ID="lblProdID" Text='<%# Eval("Id") %>' Style="visibility: hidden;"></asp:Label>
                        </ul>
                    </div>
                </div>
            </ItemTemplate>
        </asp:DataList>
 

 
This is my iframe which i pop up using div through javascript:
  <div id="myModal" class="reveal-modal">
            <h2>
                my cart - <span>You now have <span class="item">5 item(s)</span> in your cart</span></h2>
            <iframe src="../shopping-cart.aspx" width="600" height="168" scrolling="auto" frameborder="0">
            </iframe>
            <p class="grand_total">
                Grand Total (INR) : <span>4800</span></p>
            <a class="close-reveal-modal">
                <img src="../images/corss-red.png" /></a>
            <table width="100%">
                <tr>
                    <td>
                    </td>
                    <td>
                    </td>
                </tr>
                <tr>
                    <td width="100%" align="right">
                        <span style="padding: 10px 10px 0 0;">
                            <asp:ImageButton ID="imgContiShopping" CssClass="close-reveal-modal continue_shoping"
                                Height="30px" Width="80px" ImageUrl="~/images/Continue.jpeg" runat="server" OnClick="imgContiShopping_Click" /></span>
                        <span style="padding: 10px 10px 0 0;">
                            <asp:ImageButton ID="imgCheckOut" CssClass="close-reveal-modal checkout_bt" Height="30px"
                                Width="80px" ImageUrl="~/images/CheckOut.jpeg" runat="server" OnClick="imgCheckOut_Click" /></span>
                    </td>
                </tr>
            </table>
        </div>
 
And this is my code behind:
 if (e.CommandName == "Select")
        {
            int iProductId = Convert.ToInt32(((Label)e.Item.FindControl("lblProdID")).Text);
            string str_ProdName = Convert.ToString(((Label)e.Item.FindControl("lbl_ProdName")).Text);
            int iQuantity = Convert.ToInt32(((Label)e.Item.FindControl("lbl_quntity")).Text);
            int i_Price = Convert.ToInt32(((Label)e.Item.FindControl("lbl_price")).Text);
            string strImgUrl = Convert.ToString(((HtmlImage)e.Item.FindControl("img_thumb")).Src);
            int iTotal = i_Price * iQuantity;
 
            AddToCart(iProductId, str_ProdName, iQuantity, i_Price, iTotal, strImgUrl);
       
            
            Response.Redirect("../shopping-cart.aspx");
 
           
        }
 
Please help me !
Posted 3-Nov-12 1:47am
Comments
aspnet_regiis -i at 4-Nov-12 11:37am
   
" problem of displaying the shopping cart smoothly"
"but java script doesn't works"
 
are not proper technical descriptions of the problem. I don't think you will ever get an answer to your question
Subhabrata Bose at 4-Nov-12 11:52am
   
First of all check the shopping cart program again without using these popups and every thing. After this is complete then add items one by one with each step testing. Besides shopping cart is the most important and toughest part of an online shopping website. Try it again. Besides I can solve this against a remuneration.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 385
1 Sergey Alexandrovich Kryukov 195
2 Prakriti Goyal 177
3 jlopez788 134
4 Kruti Joshi 117
0 OriginalGriff 6,742
1 Sergey Alexandrovich Kryukov 5,479
2 Maciej Los 3,474
3 Peter Leow 3,313
4 DamithSL 2,505


Advertise | Privacy | Mobile
Web02 | 2.8.140721.1 | Last Updated 3 Nov 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100