Click here to Skip to main content
15,895,370 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
actually i have a carttable , which is assigned in a session...
whenever addtocart button clicked of any product in product_details page thn quantity also sends to cart page through the query string , and gets navigate to the cart_page and fills also the txtbox value for quantity..Also want to update the total (i mean the whole row will update)

now want to update that txtbox in cartpage
, so that i'd written this script, but didnt worked-->

.cs

protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {

            if (Session["cart_table"] == null)
            {
                DataTable dt = new Spcart().GetCart();
                Session["cart_table"] = dt;                   
            }
            BindCartListView();
        }
    }

   
    public void BindCartListView()
    {
       
            DataTable producttable = new BALCate().GetProductDeatils(int.Parse(Request.QueryString["pid"].ToString()));
            DataTable carttable = (DataTable)Session["cart_table"];
            DataRow cartrow;
            DataRow productrow;
            
                cartrow = carttable.NewRow();
                productrow = producttable.Rows[0];
                cartrow["Pid"] = productrow["pid"];
                cartrow["PImage"] = productrow["pimg_mid1"];
                cartrow["Pprice"] = productrow["pcost"];
                cartrow["Pqty"] = Request.QueryString["qty"];                             
                cartrow["Pname"] = productrow["pname"];

                cartrow["Total"] = int.Parse(productrow["pcost"].ToString()) * int.Parse(cartrow["Pqty"].ToString());  

                cartrow["GrandTotal"] = cartrow["Total"];
                carttable.Rows.Add(cartrow);
           
            }


     protected void ListView_Cart_ItemUpdating(object sender, ListViewUpdateEventArgs e)
        {
            int id = (int)ListView_Cart.DataKeys[e.ItemIndex].Value;
            DataTable dt = (DataTable)Session["cart_table"];
            dt.Rows.Find(id).AcceptChanges();
            Session["cart_table"] = dt;
            msgdelete.Style.Add("display", "block");
            BindCartListView();
        }


i was not sure abt tht the **accept changes() will work , but tried..........
is there any other way to do this ????????

.aspx

<asp:LinkButton ID="imgupdatebtn" runat="server" ToolTip="Update" AlternateText="Update"
                                      CommandName="Update" ><img src="Images/update.png" /></asp:LinkButton>
Posted

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900