Click here to Skip to main content
13,549,468 members
Rate this:
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"
             <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 class="prd_descrip">
                         <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>
                             <asp:Label runat="server" ID="lbl_quntity" Text='<%# Eval("Quantity") %>'></asp:Label>
                         <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>

This is my iframe which i pop up using div through javascript:
<div id="myModal" class="reveal-modal">
              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">
          <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%">
                  <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>

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);



Please help me !
Posted 3-Nov-12 1:47am
aspnet_regiis -i 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 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
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web04-2016 | 2.8.180515.1 | Last Updated 3 Nov 2012
Copyright © CodeProject, 1999-2018
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